Cod sursa(job #386760)
Utilizator | Data | 25 ianuarie 2010 21:06:24 | |
---|---|---|---|
Problema | Factorial | Scor | 0 |
Compilator | cpp | Status | done |
Runda | 1_24_2010 | Marime | 0.38 kb |
#include<fstream.h>
#include<math.h>
ifstream fin("fact.in");
ofstream fout("fact.out");
long p,n,i,x;
int main()
{
fin>>p;
if(p==0)
{
fout<<1;
return 0;
}
n=p*4-1;
do
{
n++;
x=0;3
for(i=1;pow(5,i)<=n;i++)
x=x+n/pow(5,i);
if(x>p)
{
fout<<"-1";
return 0;
}
if(x==p)
{
fout<<n;
return 0;
}
}
while(n!=0);
return 0;
}