Pagini recente » Cod sursa (job #1734460) | Cod sursa (job #1314956) | Cod sursa (job #2867753) | Cod sursa (job #384459) | Cod sursa (job #95623)
Cod sursa(job #95623)
#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;
}
if (gasit)
{
long y = (a+b)/2;
while (y%5)
--y;
printf("%ld",y);
}
else
printf("-1");
return 0;
}