Pagini recente » Clasament teeesty | Cod sursa (job #1412599) | Cod sursa (job #1666201) | Cod sursa (job #524158) | Cod sursa (job #2237615)
#include <iostream>
#include <fstream>
#include <limits>
#include <vector>
std::fstream fi ("fact.in", std::ios::in);
std::fstream fo ("fact.out", std::ios::out);
int64_t numara_zerouri (int64_t n) {
int64_t c = 0;
for (int64_t d = 5; n / d > 0; d = (d << 2) + d) c += n / d;
return c;
}
int main (void) {
int64_t p;
fi >> p;
int64_t rez = [&] () -> int64_t {
int64_t l = 1, h = std::numeric_limits<int64_t>::max(), m = 0;
while (l <= h) {
m = (l + h) >> 1;
(numara_zerouri (m) < p) ? l = m + 1 : h = m - 1; }
std::vector<int64_t> rez;
while (numara_zerouri (l) == p) {
rez.push_back (l); l++;
}
return ((!rez.empty ()) ? rez.front () : (-1));
} ();
fo << rez;
return 0;
}