题目大意:求解一些数执行一定数量的 highbit \textbf{highbit} highbit 与 lowbit \textbf{lowbit} lowbit 后的值。
考场思路:分成一个个 Subtask \textbf{Subtask} Subtask 来处理。
Subtask 1: \textbf{Subtask 1:} Subtask 1:
暴力。不再多说。
Subtask 2: \textbf{Subtask 2:} Subtask 2:
考场上玄学WA(
其实按位模拟即可。 O ( n q ) \mathcal{O}(nq) O(nq) 搞定。
Subtask 3: \textbf{Subtask 3:} Subtask 3:
既然只有 1 \textbf{1} 1,把最高位乘上 2 r − l + 1 2^{r-l+1} 2r−l+1 即可。
Subtask 4: \textbf{Subtask 4:} Subtask 4:
既然只有 0 \textbf{0} 0,从低位开始模拟即可。可以证明,复杂度只有 O ( log n ) \mathcal{O}(\log n) O(logn)。
Subtask 5: \textbf{Subtask 5:} Subtask 5:
因为对 2 a 2^a 2a 形式的数,无论 highbit \textbf{highbit} highbit 还是 lowbit \textbf{lowbit} lowbit 的效果都是原数