Pagini recente » Cod sursa (job #2911216) | Cod sursa (job #2101467) | Cod sursa (job #1268898) | Cod sursa (job #995569) | Cod sursa (job #2520230)
#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;
res = -1;
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;
}