Pagini recente » Istoria paginii utilizator/axinte_dana_raluca_323ca | Cod sursa (job #803437) | Cod sursa (job #831763) | Cod sursa (job #1430914) | Cod sursa (job #1287629)
#include <cstdio>
#include <algorithm>
using namespace std;
int x, n, last;
int ok(int med){
int x = 5, Ans = 0;
while(x < med){
Ans += med / x;
x *= 5;
}
return Ans;
}
int cb(){
int st = 1, dr = 1 << 30;
while(st <= dr){
int med = (st + dr) >> 1;
if(ok(med) >= n){
last = med;
dr = med - 1;
}
else
st = med + 1;
}
if(ok(last) == n)
return last;
else
return -1;
}
int main(){
freopen("fact.in", "r", stdin);
freopen("fact.out", "w", stdout);
scanf("%d", &n);
printf("%d", cb());
return 0;
}