Cod sursa(job #2121427)
| Utilizator | Data | 3 februarie 2018 17:49:20 | |
|---|---|---|---|
| Problema | Factorial | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.55 kb |
#include <fstream>
using namespace std;
ifstream in("fact.in");
ofstream out("fact.out");
long long fact_zero(int n) {
long long s = 0;
while (n >= 5) {
s += n / 5;
n /= 5;
}
return s;
}
int cautbin(long long x) {
int r = 0, pas = 1 << 28;
while (pas != 0) {
if (fact_zero(r + pas) < x) {
r += pas;
}
pas >>= 1;
}
r++;
if (fact_zero(r) == x) return r;
return -1;
}
int main()
{
long long p;
in >> p;
out << cautbin(p);
}
