Cod sursa(job #667101)
#include <cstdio>
using namespace std;
int p;
int nr_zerouri(int nr)
{
int rasp = 0;
int put = 5;
while (nr >= put)
{
rasp += nr / put;
put *= 5;
}
return rasp;
}
int cautare_binara()
{
int poz = 0;
for (int pas = 1 << 30;pas >= 1;pas >>= 1)
if (nr_zerouri(poz + pas) < p)
poz += pas;
return poz;
}
void citire()
{
freopen ("fact.in","r",stdin);
freopen ("fact.out","w",stdout);
scanf ("%d",&p);
}
int main()
{
int rasp;
citire();
rasp = cautare_binara() + 1;
if (nr_zerouri(rasp) == p)
printf ("%d",rasp);
else printf ("-1");
return 0;
}