Cod sursa(job #668742)

Utilizator Andrei.XweCobzaru Adrian-Andrei Andrei.Xwe Data 25 ianuarie 2012 16:05:33
Problema Factorial Scor 20
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.33 kb
using namespace std;
#include<fstream>
int main()
{
long long 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;
}