Pagini recente » Cod sursa (job #903682) | Cod sursa (job #2127904) | Cod sursa (job #975300) | Cod sursa (job #635956) | Cod sursa (job #799931)
Cod sursa(job #799931)
#include<stdio.h>
int zero(int n){
int nr=0;
while(n>=5){
nr+=n/5;
n/=5;
}
return nr;
}
int caut(int x){
int i=0,pas;
pas=1<<29;
while(pas!=0)
{
if(zero(i+pas)<x)
i += pas;
pas /= 2;
}
return i+1;
}
int main(){
freopen("fact.in","r",stdin);
freopen("fact.out","w",stdout);
int p, r;
scanf("%d",&p);
r = caut(p);
if(zero(r)==p)
printf("%d\n",r);
else
printf("-1");
return 0;
}