Pagini recente » Cod sursa (job #1845289) | Cod sursa (job #329386) | Cod sursa (job #2293493) | Cod sursa (job #3225112) | Cod sursa (job #2093414)
#include <cstdio>
int P, N, step = 536870912;
int zeroes(int N)
{
for(int i = 5, z = 0;; i *= 5)
{
z += N / i;
if(i > N) return z;
}
};
int main(){
freopen("fact.in", "r", stdin);
freopen("fact.out", "w", stdout);
scanf("%d", &P);
for(N = 400000015; step; step >>= 1)
if(zeroes(N - step) >= P) N -= step;
printf("%d", zeroes(N) != P ? -1 : P ? N : 1);
return 0;
}