Pagini recente » Cod sursa (job #1317502) | Cod sursa (job #1045882) | Cod sursa (job #2832124) | Cod sursa (job #1056750) | Cod sursa (job #141326)
Cod sursa(job #141326)
#ifdef WIN32
#define _CRT_SECURE_NO_WARNINGS
#endif
#define MAX 1000000000
#include <stdio.h>
int zerouri(int n)
{
int z = 0, d = 5;
while (n >= d)
{
z += n / d;
d *= 5;
}
return z;
}
int main()
{
freopen("fact.in", "rt", stdin);
freopen("fact.out", "wt", stdout);
int n, step, i;
scanf("%d", &n);
for (step = 1; step < MAX; step <<= 1);
for (i = 0; step; step >>= 1)
if (zerouri(i + step) <= n)
i += step;
if (zerouri(i) == n)
if (i > 4)
printf("%d\n", i - 4);
else
printf("1\n");
else
printf("-1\n");
return 0;
}