Cod sursa(job #2666634)
| Utilizator | Data | 2 noiembrie 2020 11:33:22 | |
|---|---|---|---|
| Problema | Factorial | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.54 kb |
#include <bits/stdc++.h>
using namespace std;
int p, step, pos;
int zero(int x)
{
int p5 = 5, ans = 0;
while(x/p5){
ans += x/p5;
p5*=5;
}
return ans;
}
int main() {
freopen("fact.in", "r", stdin);
freopen("fact.out", "w", stdout);
scanf("%d", &p);
step = 1 << 30;
while(step > 0){
if (zero(pos + step) < p){
pos += step;
}
step /= 2;
}
if (zero(pos+1) == p){
printf("%d\n", pos+1);
}else{
printf("%d\n", -1);
}
return 0;
}
