Pagini recente » Cod sursa (job #890289) | Cod sursa (job #10586) | Cod sursa (job #69031) | Cod sursa (job #1701422) | Cod sursa (job #3133060)
/******************************************************************************
Online C++ Compiler.
Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.
*******************************************************************************/
#include <bits/stdc++.h>
using namespace std;
ifstream f("fact.in");
ofstream g("fact.out");
long long p,i,j;
int nr0(int x)
{ int nr5=0;
for (int i=5;i<=x;i*=5)
{ nr5+=x/i;
}
return nr5;
}
int main()
{
f>>p;
long long st=1,dr=2000000000,poz=-1,mid;
if (p==0){g<<1;return 0;}
//cout<<dr<<endl;
while (st<=dr)
{ mid=(st+dr)/2;
int x=nr0(mid);
if(x>p)dr=mid-1;
else if (x<p)st=mid+1;
else {poz=mid;dr=mid-1;}
//cout<<mid<<' '<<x<<endl;
}
//cout<<endl<<poz;
g<<poz<<'\n';
return 0;
}