Pagini recente » Cod sursa (job #1376243) | Cod sursa (job #551902) | Cod sursa (job #3279308) | Cod sursa (job #724788) | Cod sursa (job #2609116)
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("fact.in");
ofstream fout("fact.out");
typedef long long LL;
LL n, p, st, dr, m, r;
LL zero(LL x)
{
LL nr=0;
LL p=5;
while(x>=p)
{
nr=nr+(x/p);
p=p*5;
}
return nr;
}
int main()
{
fin>>p;
if(p==0) fout<<"1"<<"\n";
else
{
st=1; dr=p*5+100;
while(st<=dr)
{
m=(st+dr)/2;
if(zero(m)>=p) dr=m-1;
else st=m+1;
}
if(zero(st)==p) fout<<st<<"\n";
else fout<<"-1"<<"\n";
}
return 0;
}