Cod sursa(job #1748742)
| Utilizator | Data | 26 august 2016 18:48:30 | |
|---|---|---|---|
| Problema | Factorial | Scor | 90 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.62 kb |
#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));
}
