Pagini recente » Cod sursa (job #1655648) | Cod sursa (job #620784) | Cod sursa (job #2126344) | Cod sursa (job #2829351) | Cod sursa (job #403032)
Cod sursa(job #403032)
#include <stdio.h>
int main()
{
long long s,m;
long a=0,b=500000000,x=250000000,p;
freopen("fact.in","r",stdin);
freopen("fact.out","w",stdout);
scanf("%ld",&p);
int y=0;
if(p==0){
printf("1");
}else{
while(a<b-1 && y==0){
s=0;
m=5;
while(m<=x){
s=s+x/m;
m=m*5;
}
if(s>p){
b=x;
x=(a+b)/2;
}
if(s<p){
a=x;
x=(a+b)/2;
}
if(s==p){
y=1;
}
}
if(y==1){
printf("%ld",x-x%5);
}else{
printf("-1");
}
}
return 0;
}