Cod sursa(job #126971)
Utilizator | Data | 23 ianuarie 2008 00:14:08 | |
---|---|---|---|
Problema | Factorial | Scor | 5 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.38 kb |
#include <fstream.h>
#include <iostream.h>
int main()
{
ifstream fin("fact.in");
ofstream fout("fact.out");
long n=0,c=5,p;
short ct=0;
fin>>p;
while (ct<p)
{
n=n+1;
ct=ct+1;
if (c!=5) c=5;
while (n%c==1)
{
ct=ct+1;
c=c*5;
}
}
n=n*5;
if (p==0) n=1;
if (ct!=p) n=-1;
fout<<n;
return 0;
}