Pagini recente » Cod sursa (job #2607512) | Cod sursa (job #2121358) | Cod sursa (job #2554152) | Cod sursa (job #223978) | Cod sursa (job #916183)
Cod sursa(job #916183)
#include <iostream>
#include <fstream>
using namespace std;
long p,k,nr,h,i,hh;
int main()
{
ifstream fin("fact.in");
ofstream fout("fact.out");
fin>>p;
k=0;
nr=0;
h=0;
i=6;
if(p==0)fout<<"1";
else
{
while(nr+i<p)
{
nr+=i;
h+=25;
k++;
if(k==4)
{
k=0;
i++;
}
}
if(p%2==1)nr--;
if(nr==p)fout<<h;
else
{
while(nr<p)
{
h+=5;
hh=h;
while(hh%5==0)
{
nr++;
hh/=5;
}
}
fout<<h;
}
}
fin.close();
fout.close();
}