Pagini recente » Cod sursa (job #2640894) | Cod sursa (job #798666) | Cod sursa (job #2966035) | Cod sursa (job #1128692) | Cod sursa (job #281599)
Cod sursa(job #281599)
#include <stdio.h>
#define MAX 100000000
int n;
int bin(int p)
{
int hi,mid,lo,e,a,max;
for (lo=1,hi=10^8+1, max=-1; lo<=hi; )
{
mid=lo+(hi-lo)/2;
a=mid;
e=0;
while(a)
e+=(a/=5);
if (e==p)
max=mid;
if(p<=e)
hi=mid-1;
else if(p>e)
lo=mid+1;
}
if (max!=-1)
return max;
return -1;
}
int main()
{
freopen ("fact.in","r",stdin);
freopen ("fact.out","w",stdout);
scanf ("%d",&n);
if (n==0)
printf ("1");
else
printf ("%d",bin(n));
return 0;
}