Pagini recente » Cod sursa (job #1075724) | Cod sursa (job #1508625) | Cod sursa (job #887948) | Cod sursa (job #1278464) | Cod sursa (job #2520201)
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin ( "fact.in" );
ofstream fout ( "fact.out" );
const int NMAX = 1e8;
const int P = 5;
int main()
{
int n, st, dr;
int x, res;
int f0, pwr;
fin >> n;
st = 1;
dr = NMAX;
while ( st <= dr ){
x = st + ( dr - st ) / 2;
f0 = 0;
pwr = 1;
while ( pwr <= x ){
pwr *= P; /// ar fi trebuit sa aleg min, dar stiu sigur ca cu 5 e min
f0 += ( x / pwr );
}
if ( f0 == n ){
dr = x - 1;
res = x;
}
else if ( f0 < n )
st = x + 1;
else
dr = x - 1;
}
fout << res;
return 0;
}