Pagini recente » Cod sursa (job #3208029) | Cod sursa (job #3260770) | Cod sursa (job #105925) | Cod sursa (job #2486379) | Cod sursa (job #95624)
Cod sursa(job #95624)
#include <stdio.h>
#include <math.h>
long p,a = 1,b = 1000000000,gasit;
long auxi ;
long zerouri (int x)
{
long put = 0;
auxi = x;
while (auxi > 0)
{
put += auxi / 5;
auxi /= 5;
}
return put;
}
int main ()
{
long aux;
freopen("fact.in","r",stdin);
freopen("fact.out","w",stdout);
scanf("%ld",&p);
while (a != b && !gasit)
{
aux = zerouri((a+b)/2);
if (aux == p)
gasit = 1;
else
if (aux < p)
a = (a+b)/2 + 1;
else
b = (a+b)/2;
}
long y;
if (gasit)
{
y = (a+b)/2;
while (y%5)
--y;
if (!y)
y = 1;
printf("%ld",y);
}
else
printf("-1");
return 0;
}