Pagini recente » Cod sursa (job #664396) | Cod sursa (job #2156980) | Cod sursa (job #1212981) | Profil Saitama | Cod sursa (job #2333737)
#include <bits/stdc++.h>
using namespace std;
ifstream fin ("fact.in");
ofstream fout ("fact.out");
int n,p;
long long ans-1;
int zero(int x)
{
int nr=0;
int fact=5;
while(x>=fact)
{
nr+=x/fact;
fact=5*fact;
}
return nr;
}
void solve()
{
int st=1,dr=1e8,mij;
while(st<=dr)
{
mij=st+(dr-st)/2;
int rez=zero(mij);
if(rez==p)
{
ans=mij;
dr=mij-1;
}
else if(rez<p)
{
st=mij+1;
}
else
{
dr=mij-1;
}
}
fout<<ans;
}
int main()
{
fin>>p;
solve();
return 0;
}