Pagini recente » Cod sursa (job #236848) | Cod sursa (job #1188198) | Cod sursa (job #2488884) | Cod sursa (job #1140503) | Cod sursa (job #341292)
Cod sursa(job #341292)
#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<200000) {N=400005;put=100000;};
if(P>=200000 && P<500000) {N=800005;put=200000;};
if(P>=500000 ) {N=2000005;put=500000;};
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;
}