Pagini recente » Cod sursa (job #2396326) | Cod sursa (job #2973560) | Cod sursa (job #1722172) | Cod sursa (job #2732954) | Cod sursa (job #2612025)
#include <iostream>
#include <fstream>
using namespace std;
long nr_0(long x){
long pow = 5, nr = 0;
while(x/pow>0){
nr+=x/pow;
pow*=5;
}
return nr;
}
int caut_binar(int l, int r,int p){
if(l>r) return -1;
int md = l+(r-l)/2, nr = nr_0(md);
if(nr==p){
while(nr_0(--md)==p);
return md+1;
}
if(nr>p) return caut_binar(l, md, p);
return caut_binar(md+1, r, p);
}
int main() {
ifstream fin("fact.in");
ofstream fout("fact.out");
long p;
fin>>p;
if(p==0) fout<<1;
else
fout<<caut_binar(1, p*10, p);
return 0;
}