Cod sursa(job #2080190)

Utilizator MasterOfLoreBogdan Surdu MasterOfLore Data 2 decembrie 2017 15:54:07
Problema Factorial Scor 45
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.44 kb
#include <iostream>
#include <fstream>
using namespace std;
ifstream f("fact.in");
ofstream g("fact.out");
int P;
int zerouri(int x)
{
    int ans = 1;
    x/=5;
    while(!(x%5))
    {
        x/=5;
        ans++;
    }
    return ans;
}
int main()
{
    f >> P;
    int n = 5;
    if(P==0) g << 1 << endl;
    else{
    while(P)
    {
        P = P - zerouri(n);
        n+=5;
    }
    g << n-5 << endl;
    }

}