Cod sursa(job #538870)
Utilizator | Data | 21 februarie 2011 23:20:03 | |
---|---|---|---|
Problema | Factorial | Scor | 10 |
Compilator | cpp | Status | done |
Runda | contest- | Marime | 0.4 kb |
#include<math.h>
#include<fstream.h>
ifstream fin("fact.in");
ofstream fout("fact.out");
long p,n,i,j,x,ci;
int main()
{
fin>>p;
if(p)
{
n=9;
do
{
n++;
x=0;
for(i=5;i<=n;i=i+5)
{
ci=i;
while(ci%5==0)
{
x=x+ci/5;
ci=ci/5;
}
}
}
while(x<p);
if(x>p)
fout<<"-1";
else
fout<<n;
}
else
fout<<"1";
return 0;
}