Pagini recente » Statistici Gutica Stefan (StefanGtz) | Statistici FIIApetroaieiBurlicaCuciureanu (FIIABC) | Cod sursa (job #758403) | Cod sursa (job #2152689) | Cod sursa (job #457321)
Cod sursa(job #457321)
#include<stdio.h>
#define infile "fact.in"
#define outfile "fact.out"
long n;
void read()
{
scanf("%ld",&n);
}
long f(long n)
{
long rez=0,x=1;
while(x<=n)
{
x=x*5;
rez+=n/x;
}
return rez;
}
void solve()
{
long a=1,b=5*n,m,x=0,q;
while(a<=b && x==0)
{
m=(a+b)/2;
q=f(m);
if(q==n)
x=m;
if(q<n)
a=m+1;
if(q>n)
b=m-1;
}
while(x%5!=0)
x--;
if(x==0)
x=-1;
if(n==0)
x=1;
printf("%ld",x);
}
int main()
{
freopen(infile,"r",stdin);
freopen(outfile,"w",stdout);
read();
solve();
fclose(stdin);
fclose(stdout);
return 0;
}