Pagini recente » Cod sursa (job #1652429) | Cod sursa (job #800146) | Cod sursa (job #571554) | Cod sursa (job #41709) | Cod sursa (job #582848)
Cod sursa(job #582848)
#include <cstdio>
using namespace std;
int p;
int cauta_b(int l,int r)
{
int k=(l+r)/2,n=k,ok=0;
while(n/5!=0)
{
n/=5;
ok+=n;
}
if(ok==p)
return k;
else if(ok>p) cauta_b(l,k);
else cauta_b(k+1,r);
}
int main()
{
int i,n,ok;
freopen("fact.in","r",stdin);
freopen("fact.out","w",stdout);
scanf("%d",&p);
if(p==0)
{
printf("1");
return 0;
}
n=cauta_b(p,100000000);
printf("%d",n);
fclose(stdout);
return 0;
}