Pagini recente » Cod sursa (job #1838846) | Cod sursa (job #2682425) | Cod sursa (job #2742231) | Cod sursa (job #1134343) | Cod sursa (job #2495170)
#include <iostream>
#include<fstream>
#include<cstring>
#include<algorithm>
#include<iomanip>
#define N 100005
using namespace std;
ifstream fin("fact.in");
ofstream fout("fact.out");
//cautare binara
int p;
int exp5(int x)
{
int r=5,ct=0;
while(r<=x)
{
ct+=x/r;
r*=5;
}
return ct;
}
void solve()
{
int s=1,d=p*10,x,m;
bool gasit=false;
//cout<<s<<" "<<d;
while(s<d&&gasit==false)
{
m=(s+d)/2;
//cout<<1;
x=exp5(m);
// cout<<x<<" ";
if(x==p)
{gasit=true;}
else
if(x>p)d=m-1;
else s=m+1;
}
while(m%5!=0)m--;
//cout<<exp5(m);
fout<<m;
}
int main()
{
fin>>p;
//cout<<exp5(45);
if(p==0)fout<<1;
else solve();
return 0;
}