Pagini recente » Cod sursa (job #339936) | Cod sursa (job #1993025) | Cod sursa (job #3253766) | Rating anonim (Sesshy) | Cod sursa (job #121387)
Cod sursa(job #121387)
#include<stdio.h>
long p,st,dr,nr;
long mul(long m)
{
long putere;
nr=0;
putere=5;
while(m/putere)
{
nr=nr+m/putere;
putere=putere*5;
}
return nr;
}
long bi(long st, long dr)
{
long m;
m=(st+dr)>>1;
nr=mul(m);
if(nr==p)
{
// m=m-m%5;
return m-m%5;
}
if(nr>p)
return bi(st,m-1);
return bi(m+1,dr);
}
int main()
{
freopen("fact.in","r",stdin);
freopen("fact.out","w",stdout);
scanf("%ld",&p);
if(p==0)
{
printf("1");
return 0;
}
printf("%ld",bi(p*4,p*5));
return 0;
}