Pagini recente » Cod sursa (job #1573396) | Cod sursa (job #305591) | Clasament rommmmm | Cod sursa (job #676046) | Cod sursa (job #509261)
Cod sursa(job #509261)
#include<cstdio>
void read(),solve();
long long mij,nr,st,dr,P,aux;
int main()
{
read();
solve();
return 0;
}
void read()
{
freopen("factorial.in","r",stdin);
freopen("factorial.out","w",stdout);
scanf("%d",&P);
}
void solve()
{
if(P==0){printf("1\n");return;}
if(P==1){printf("0\n");return;}
for(st=1,dr=500000000;dr-st-1;)
{
mij=(st+dr)/2;
nr=0;
for(aux=5;aux<=mij;aux*=5)nr+=mij/aux;
if(nr==P){mij-=mij%5;printf("%d\n",mij);return;}
if(nr<P)st=mij; else dr=mij;
}
printf("-1\n");
}