Pagini recente » Cod sursa (job #53525) | Cod sursa (job #2631659) | Cod sursa (job #2677278) | Cod sursa (job #2335328) | Cod sursa (job #341294)
Cod sursa(job #341294)
#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 && P<3000000) {N=2000005;put=500000;};
if(P>=3000000 &&P<10000000) {N=12000010;put=3000000;};
if(P>=10000000) {N=40000010;put=10000000;};
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;
}