Cod sursa(job #668741)
| Utilizator | Data | 25 ianuarie 2012 16:03:34 | |
|---|---|---|---|
| Problema | Factorial | Scor | 20 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.34 kb |
using namespace std;
#include<fstream>
int main()
{
long long N,P,i,nr=0,a;
ifstream fcin("fact.in");
ofstream fcout("fact.out");
fcin>>P;
if (P<0)
fcout<<-1;
else
if(P==0)
fcout<<1;
else
{
for(i=5;nr<P;i+=5)
{
a=i;
while (a%5==0)
{
a/=5;
if(nr<P)
nr++;
}
}
fcout<<i-5;
}
fcin.close();
fcout.close();
return 0;
}
