Cod sursa(job #492886)
Utilizator | Data | 16 octombrie 2010 11:40:52 | |
---|---|---|---|
Problema | Factorial | Scor | 95 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.62 kb |
#include<fstream>
using namespace std;
long long int p,n,k,ok,x;
int main()
{
ifstream fin("fact.in");
ofstream fout("fact.out");
fin>>p;
if(p==0)
fout<<1;
else {
for(n=4*p;n<=5*p;n++)
{
k=0;
x=n;
while(x)
{
k+=x/5;
x/=5;
}
if(k==p)
{
fout<<n;
n=5*p+1;
ok=1;
}
}
if(ok==0)
fout<<-1;
}
}