Cod sursa(job #21441)
Utilizator | Data | 23 februarie 2007 15:27:45 | |
---|---|---|---|
Problema | Factorial | Scor | 45 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.26 kb |
#include<fstream.h>
main() {
long n,m,p;
ifstream f("fact.in");
ofstream g("fact.out");
f>>p;
if(p==1) g<<0;
if(p%5==0) g<<-1;
else {
n=5;
while(p) {
m=n;
while(m%5==0) {m/=5;p--;}
n+=5;
}
g<<n-5;
}
return 0;
}