Pagini recente » Cod sursa (job #3155483) | Cod sursa (job #1627500) | Cod sursa (job #1185826) | Cod sursa (job #2118396) | Cod sursa (job #2520210)
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin ( "fact.in" );
ofstream fout ( "fact.out" );
const long long NMAX = 1e13;
const int P = 5;
int main()
{
int n;
long long st, dr;
int x, res;
int f0, pwr;
fin >> n;
st = 0;
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;
}