Pagini recente » Cod sursa (job #2765080) | Cod sursa (job #694270) | Cod sursa (job #2111331) | Cod sursa (job #1818335) | Cod sursa (job #2520223)
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin ( "fact.in" );
ofstream fout ( "fact.out" );
const int NMAX = 1e9;
const int P = 5;
int main()
{
int n;
int 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 = P;
while ( pwr <= x ){
f0 += ( x / pwr );
pwr *= P; /// ar fi trebuit sa aleg min, dar stiu sigur ca cu 5 e min
}
if ( f0 == n ){
dr = x - 1;
res = x;
}
else if ( f0 < n )
st = x + 1;
else
dr = x - 1;
}
fout << res;
return 0;
}