Cod sursa(job #341279)
Utilizator | Balan Radu Cosmin Cosmin1490 | Data | 17 august 2009 22:42:20 |
---|---|---|---|
Problema | Factorial | Scor | 60 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.46 kb |
#include <fstream.h>
ifstream fin("fact.in");
ofstream fout("fact.out");
long P,N,put;
void factorial()
{
long z;put=1;
if (P==0) N=1;
else if (P==1) N=5;
else { N=5;
if(P>=100000) { N=400005;put=100000;}
while (put<P)
{N=N+5;z=N;
while (z%5==0)
{z=z/5;
put=put+1;
}
}
}
}
int main()
{fin>>P;
factorial();
if (put>P&&P>3) N=-1;
fout<<N;
fin.close();
fout.close();
return 0;
}