Pagini recente » Cod sursa (job #46079) | Cod sursa (job #2790080) | Cod sursa (job #958521) | best | Cod sursa (job #1024075)
#include <iostream>
#include<fstream>
using namespace std;
int p;
ifstream f("fact.in");
ofstream g("fact.out");
int fun(long long x)
{
long long c=5,nr=0;
while(x/c!=0)
{
nr=nr+x/c;
c=c*5;
}
return nr;
}
int binary(long long st,long long dr)
{
long long med,x;
while(st<=dr)
{
med=(st+dr)/2;
x=fun(med);
if(p==x&&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;
}