Cod sursa(job #303036)
Utilizator | Data | 9 aprilie 2009 14:49:58 | |
---|---|---|---|
Problema | Factorial | Scor | 15 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.37 kb |
#include<math.h>
#include<fstream.h>
ifstream fin("fact.in");
ofstream fout("fact.out");
long p,n,i,j,x;
int main()
{
fin>>p;
if(p)
{
n=9;
do
{
n++;
i=0;
x=0;
do
{
i++;
x=x+n/(long)pow(5,i);
}
while(pow(5,i)<=n);
}
while(x<p);
if(x>p)
fout<<"-1";
else
fout<<n;
}
else
fout<<"1";
return 0;
}