Cod sursa(job #351343)
Utilizator | Data | 27 septembrie 2009 18:27:20 | |
---|---|---|---|
Problema | Factorial | Scor | 100 |
Compilator | cpp | Status | done |
Runda | info.conc.sept.2 | 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;
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;
}