P9223 「PEOI Rd1」异或(xor)
题目描述
给定两个正整数 $n,m$,求:
$$\sum_{i=1}^{n}\sum_{j=1}^{m}\left(i \oplus j\right) $$
其中,$\oplus$ 表示按位异或运算(即 C++ 中的 `^` 符号)。答案对 $998244353$ 取模。
输入格式
无
输出格式
无
说明/提示
#### 样例解释
第一个样例第一组数据:
$\begin{aligned}&(1 \oplus 1)+(1 \oplus 2)+(2 \oplus 1)+(2 \oplus 2)\\=\ &0+3+3+0\\=\ &6\end{aligned}$
第二组数据:
$\begin{aligned}&(1 \oplus 1)+(1 \oplus 2)+(1 \oplus 3)+(2 \oplus 1)+(2 \oplus 2)+(2 \oplus 3)+(3 \oplus 1)+(3 \oplus 2)+(3 \oplus 3)\\=\ &0+3+2+3+0+1+2+1+0\\=\ &12\end{aligned}$
---
#### 数据范围
|子任务|$n,m \leq$|特殊性质|分值|
|:-:|:-:|:-:|:-:|
|$1$|$10^3$|无|$10$|
|$2$|$10^6$|无|$20$|
|$3$|$10^{16}$|A|$20$|
|$4$|$10^{16}$|无|$50$|
- 特殊性质 A:保证 $n=2^p-1$,$m=2^q-1$,其中 $p,q\in\mathbb Z$。
对于 $100\%$ 的数据,保证 $1 \leq n,m \leq 10^{16}$,$1 \leq T \leq 50$。