Cod sursa(job #2662370)
Utilizator | Data | 23 octombrie 2020 22:44:23 | |
---|---|---|---|
Problema | Factorial | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.51 kb |
#include <bits/stdc++.h>
using namespace std;
#define x1 "fact.in"
#define x2 "fact.out"
ifstream in(x1);
ofstream out(x2);
int zero(int nr) {
int ans = 0, p5 = 5;
while(p5 <= nr){
ans += nr / p5;
p5 *= 5;
}
return ans;
}
int main() {
int n, r = 0, pas = 1 << 30;
in >> n;
while(pas) {
if(zero(pas + r) < n)
r += pas;
pas /= 2;
}
if(zero(r + 1) == n)
out << r + 1;
else
out << -1;
return 0;
}