Cod sursa(job #350697)
Utilizator | Data | 25 septembrie 2009 15:35:03 | |
---|---|---|---|
Problema | Factorial | Scor | 95 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.35 kb |
#include<fstream.h>
#include<math.h>
ifstream fin("fact.in");
ofstream fout("fact.out");
long p,n,i,x;
int main()
{
fin>>p;
n=p*4-1;
do
{
n++;
x=0;
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);
fout<<"0";
return 0;
}