Pagini recente » Cod sursa (job #1253368) | Cod sursa (job #1301640) | Diferente pentru autumn-warmup-2007/solutii/runda-3 intre reviziile 37 si 36 | Monitorul de evaluare | Cod sursa (job #1024076)
#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=(st+dr)/2;
long long x=fun(med);
if(med%5==0&&x==p)
return med;
else
if(x<p)
return binary(med+1,dr);
else
return binary(st,med-1);
if(st>dr)
return -1;
}
int main()
{
long long n;
f>>p;
if(p==0)
g<<1<<endl;
else
g<<binary(1,100000000)<<endl;
return 0;
}