Cod sursa(job #581310)
| Utilizator | Data | 13 aprilie 2011 23:39:19 | |
|---|---|---|---|
| Problema | Factorial | Scor | 40 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.62 kb |
#include<iostream>
#include<fstream>
using namespace std;
int main()
{
long p,s;
int q,t,y,nr,n;
ifstream f("fact.in");
ofstream g("fact.out");
f>>p;
s=1;
nr=0; n=5; q=1;
if(p==0) g<<1;
else {
while(nr<=p-1&& q)
{
y=n; t=0;
while(y%5==0 && nr<=p-1 && q)
{ if(t<=p-nr)
{ t++;
nr++;
y=y/5; }
else {
g<<-1;
q=0;
}
}
n=n+5;
}
g<<n-5;
}
return 0;
}
