Pagini recente » Cod sursa (job #669692) | Cod sursa (job #702266) | Cod sursa (job #2901601) | Cod sursa (job #264431) | Cod sursa (job #2666634)
#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;
}