Pagini recente » Cod sursa (job #198686) | Cod sursa (job #1575523) | Cod sursa (job #1815404) | Cod sursa (job #1825706) | Cod sursa (job #2093404)
#include <cstdio>
int P, N, step;
int trailingZeroes(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(step = 1; step < 400000015; step <<= 1);
for(N = 400000015; step; step >>= 1)
if(trailingZeroes(N - step) >= P) N -= step;
printf("%d", P ? N : 0);
return 0;
}