Pagini recente » Agm 2018 Runda 1 | Istoria paginii runda/problemebarajgimnaziu/clasament | Cod sursa (job #3037902) | Cod sursa (job #2109939) | Cod sursa (job #2325979)
#ifdef INFOARENA
#include <fstream>
std::ifstream is{"fact.in"};
std::ofstream os{"fact.out"};
#else
#include <iostream>
#define is std::cin
#define os std::cout
#endif // INFOARENA
#define not_(expr) (!(expr))
int main() {
int p;
is >> p;
int acc = 1, two{}, five{};
for (; p > 0; ++acc) {
auto i = acc;
while not_ (i % 10)
--p,
i /= 10;
while not_ (i & 1)
++two,
i >>= 1;
while not_ (i % 5)
++five,
i /= 5;
auto min = std::min(two, five);
p -= min;
two -= min;
five -= min;
}
os << acc - 1;
}