Pagini recente » Cod sursa (job #127036) | Cod sursa (job #1948085) | Cod sursa (job #832337) | Cod sursa (job #2085998) | Cod sursa (job #1213565)
#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 (p==0) {cout<<1; return 0;}
if(c==-1) {cout<<c; return 0;}
while (c%5) c--;
cout<<c;
return 0;
}