Cod sursa(job #48386)
Utilizator | Data | 4 aprilie 2007 18:53:00 | |
---|---|---|---|
Problema | Factorial | Scor | 20 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.45 kb |
#include<fstream.h>
int n,p;
int main()
{
ifstream in("fact.in");
in>>p;
n=125*(p/31);
p=p-31*(p/31);
int m;
while(p>0)
{
n+=5;
m=n;
while(m%5==0)
{
m=m/5;
p--;
}
}
ofstream out("fact.out");
if (p==0)
out<<n;
if (p<0)
out<<-1;
return 0;
}