Pagini recente » Cod sursa (job #3258665) | Cod sursa (job #3154286) | Cod sursa (job #1419934) | Cod sursa (job #1007455) | Cod sursa (job #341283)
Cod sursa(job #341283)
#include <fstream.h>
ifstream fin("fact.in");
ofstream fout("fact.out");
long P,N,put;
void factorial()
{
long z;put=1;
if (P==0) N=1;
else if (P==1) N=5;
else { N=5;
if(P>=100000 && P<1000000) { N=400005;put=100000;};
if(P>=1000000) { N=400005;put=1000000;}
while (put<P)
{N=N+5;z=N;
while (z%5==0)
{z=z/5;
put=put+1;
}
}
}
}
int main()
{fin>>P;
factorial();
if (put>P&&P>3) N=-1;
fout<<N;
fin.close();
fout.close();
return 0;
}