Pagini recente » Cod sursa (job #1280339) | Cod sursa (job #1599271) | Cod sursa (job #2773175) | Cod sursa (job #260075) | Cod sursa (job #2303956)
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("fact.in");
ofstream fout("fact.out");
long long catidezero(long long P)
{
long long i=5,contor=0;
while (i<=P)
{
contor+=(P/i);
i*=5;
}
return contor;
}
int main()
{
long long P,cP;
fin >> P;
if (P==0)
{
cP=1;
fout << cP;
}
else
{
cP=P;
while (catidezero(cP)<P)
{
++cP;
}
if (catidezero(cP)==P)
{
fout << cP;
}
else
{
cP=-1;
fout << cP;
}
}
return 0;
}