Cod sursa(job #673250)

Utilizator al.mocanuAlexandru Mocanu al.mocanu Data 4 februarie 2012 10:28:46
Problema Factorial Scor 25
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.31 kb
#include <fstream>
using namespace std;

ifstream f("fact.in");
ofstream g("fact.out");

long long P,N,i=5,k,j;

int main()
{f>>P;
if(P==0)
g<<'1';

else
{N=0;
while(N<P)
{k=i;
j=0;
while(k%5==0)
{
    k=k/5;
    j++;
}
i=i+5;
N=N+j;
}

if(N==P)
g<<i-5;

else
g<<"-1";}

    return 0;
}