Pagini recente » Cod sursa (job #2167468) | Cod sursa (job #2092470) | Cod sursa (job #2099575) | Cod sursa (job #2330690) | Cod sursa (job #237859)
Cod sursa(job #237859)
#include<stdio.h>
long P;
long nrz(long n)
{ long nrz=0;
while(n!=0)
{
nrz+=n/5;
n/=5;
}
return nrz;
}
int main()
{
freopen("fact.in","r",stdin);
freopen("fact.out","w",stdout);
scanf("%ld",&P);
long st=0,dr=200000000;
if(P==0)
printf("1\n");
while (st<=dr)
{
long mij=(dr+st)/2;
long nrm=nrz(mij);
if (nrm==P)
{ if(mij%5==0)
printf("%ld\n",mij);
else {while(mij%5!=0)
mij--;
printf("%ld\n",mij);
}
break;
}
else if (nrm>P)
dr=mij-1;
else
st=mij+1;
}
return 0;
}