Pagini recente » Cod sursa (job #2311485) | Cod sursa (job #2689725) | Cod sursa (job #2704242) | Clasamentul arhivei Infoarena Monthly | Cod sursa (job #2338471)
# include <iostream>
# include <fstream>
# include <algorithm>
# include <cmath>
# include <cctype>
# include <cstring>
# include <queue>
# include <stack>
# include <unordered_map>
using namespace std;
ifstream fi ("fact.in");
ofstream fo ("fact.out");
int p, rez, st, dr, mij;
int legrande(int numar) {
int e = 0;
int putere = 5;
while (putere <= numar) {
e += (int)numar / putere;
putere *= 5;
}
return e;
}
int main ()
{
fi >> p;
st = 1;
dr = 1 << 30;
while (st <= dr) {
mij = (st + dr) >> 1;
if (legrande(mij) == p) {
rez = mij;
dr = mij - 1;
}
if (legrande(mij) < p)
st = mij + 1;
else
if (legrande(mij) > p)
dr = mij - 1;
}
fo << rez;
return 0;
}