Pagini recente » Cod sursa (job #2941199) | Cod sursa (job #28599) | Cod sursa (job #849413) | Cod sursa (job #1420223) | Cod sursa (job #1213562)
#include<fstream>
#define LL long long
using namespace std;
ifstream cin("fact.in");
ofstream cout("fact.out");
LL p,n;
LL nr0(LL x)
{
LL c=0,k=5;
while (k<=x)
{
c+=x/k;
k*=5;
}
return c;
}
int CautBin(LL l,LL r)
{
if (l>r) return -1;
int m=(l+r)/2, x=nr0(m);
if (x==p) return m;
if (x>p) return CautBin(l,m-1);
else return CautBin(m+1,r);
}
int main()
{
cin>>p;
LL c=CautBin(1,20000000000);
if(c==-1) {cout<<c; return 0;}
while (c%5) c--;
cout<<c;
return 0;
}