Pagini recente » Cod sursa (job #1787446) | Cod sursa (job #2719135) | Cod sursa (job #2410619) | Cod sursa (job #2089306) | Cod sursa (job #1748742)
#include <stdio.h>
#define MAX 1000000000
int cinci(long long p)
{
int pow = 1, s = 0;
while ( pow * 5 <= p)
{
pow *= 5;
s += p/pow;
}
return s;
}
long long caut_bin(long long a, long long b, int p)
{
long long mid;
while( b - a > 1)
{
mid = (b + a) / 2 ;
if (cinci(mid) < p)
a = mid;
else
b = mid;
}
return b;
}
int main(void)
{
long long p;
freopen("fact.in", "r", stdin);
freopen("fact.out", "w", stdout);
scanf("%lld", &p);
printf("%lld \n", caut_bin(0,MAX,p));
}