Pagini recente » Cod sursa (job #3198376) | Cod sursa (job #2075970) | Cod sursa (job #1123835) | Cod sursa (job #1665259) | Cod sursa (job #1722314)
#include <iostream>
#include <fstream>
using namespace std;
ifstream in("fact.in");
ofstream out("fact.out");
long long int low=1,mid,high=1000000000,answer;
long long int x;
int nrzero(int n)
{
long int five=5,result=0;
while(n>=five)
{
result=result+n/five;
five=five*5;
}
return result;
}
int BinarySearch(int p)
{
answer=1;
while(low<=high)
{
mid=low+(high-low)/2;
x=nrzero(mid);
if(x==p)
{
answer=mid;
high=mid-1;
}
else if(x<p)
{
low=mid+1;
}
else
{
high=mid-1;
}
}
return answer;
}
int main()
{
long long int p,x;
cin>>p;
x=BinarySearch(p);
cout<<x;
}