Pagini recente » Cod sursa (job #1857310) | Cod sursa (job #2404401) | Cod sursa (job #2468836) | Cod sursa (job #854252) | Cod sursa (job #1024079)
#include <iostream>
#include<fstream>
using namespace std;
int p;
ifstream f("fact.in");
ofstream g("fact.out");
int fun(long long mid)
{
long x,y;
x=0;
y=5;
while(y<=mid)
{
x=x+mid/y;
y=y*5;
}
return x;
}
int binary(long long st,long long dr)
{
while(st<=dr)
{
long med=(st+dr)/2;
long x=fun(med);
if(x==p && med%5==0)
{
return med;
}
else
{
if(x<p)
st=med+1;
else
dr=med-1;
}
}
return -1;
}
int main()
{
long long n;
f>>p;
if(p==0)
g<<1<<endl;
else
g<<binary(1,100000000)<<endl;
return 0;
}