Pagini recente » Cod sursa (job #1278179) | Cod sursa (job #1440835) | Cod sursa (job #2299709) | Cod sursa (job #1569637) | Cod sursa (job #401715)
Cod sursa(job #401715)
# include <cstdio>
int expo (long long a)
{
int nr=0;
while (a>0)
{
nr=nr+a/5;
a=a/5;
}
return nr;
}
int main ( )
{
freopen ("fact.in","r",stdin);
freopen ("fact.out","w",stdout);
long long n,p,max,min,t,x;
scanf ("%lld",&p);
max=500000000;
min=0;
t=0;//inca nu l-am gasit pe n
while (t==0 && min<=max)
{
x=expo((max+min)/2);
if(p>x)
min=(max+min)/2+1;
if (p<x)
max=(max+min)/2-1;
if (p==x)
{
n=(max+min)/2;
n=n-n%5;
t=1;
}
}
if (t==0)
printf("-1");
else
{
if (n==0)
n=1;
printf ("%lld",n);
}
return 0;
}