Pagini recente » Cod sursa (job #188438) | Cod sursa (job #217569) | Cod sursa (job #1009826) | Cod sursa (job #1877166) | Cod sursa (job #1652318)
#include <iostream>
#include <cstdio>
#define MAXVAL 0x3fffffff
using namespace std;
int zeros(int val)
{
int rez = 0;
for (int i = 5; i <= val; i*=5)
rez += val / i;
return rez;
}
int main()
{
freopen("fact.in", "r", stdin);
freopen("fact.out", "w", stdout);
int p;
scanf("%d", &p);
int step;
for (step = 1; step < MAXVAL; step <<= 1);
int rez = MAXVAL, aux;
for (int i = 1; step; step >>= 1)
if (rez - step > 0 && zeros(rez - step) >= p)
rez -= step;
if (zeros(rez) == p)
printf("%d", rez);
else
printf("%d", -1);
return 0;
}