Pagini recente » Cod sursa (job #2021222) | Cod sursa (job #2961923) | Monitorul de evaluare | Cod sursa (job #326164) | Cod sursa (job #916210)
Cod sursa(job #916210)
#include <iostream>
#include <fstream>
using namespace std;
long p,k,nr,h,i,hh,OK;
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++;
hh=h;
while(hh%5==0)
{
nr++;
hh/=5;
}
nr-=2;
}
if(nr==p)fout<<h;
else
{
while(nr<p)
{
h+=5;
hh=h;
while(hh%5==0)
{
nr++;
hh/=5;
}
}
if(p==nr) fout<<h;
else fout<<"-1";
}
}
fin.close();
fout.close();
}