Approach hintTry it first, then revealHide
The first ceil(n / 2) positions hold the odd numbers; decide which half position k falls in and compute the value directly. Both n and k reach 10^12, so use long long.
The first ceil(n / 2) positions hold the odd numbers; decide which half position k falls in and compute the value directly. Both n and k reach 10^12, so use long long.