Cod sursa(job #146023)
| Utilizator | Data | 1 martie 2008 01:27:05 | |
|---|---|---|---|
| Problema | Factorial | Scor | 25 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.53 kb |
#include<fstream.h>
long int n,p,aux,x=0,i=0;
int main ()
{
ifstream f("fact.in");
ofstream g("fact.out");
f>>p;
if (p==0) g<<1;
else {
while (x<p)
{i=i+5;aux=i;
if (aux%5==0) if (aux%25==0) if (aux%125==0) if (aux%625==0) if (aux%3125==0) if (aux%15625==0) {x+=6;}
else {x+=5;}
else {x+=4;}
else {x+=3;}
else {x+=2;}
else (x++);
}
if (x==p) g<<i;
else g<<-1;
}
f.close();
g.close();
return 0;
}
