#15435. 「PEOI Rd1」异或(xor)
「PEOI Rd1」异或(xor)
「PEOI Rd1」异或(xor)
题目描述
给定两个正整数 $n,m$,求: $$\sum_{i=1}^{n}\sum_{j=1}^{m}\left(i \oplus j\right)$$其中, 表示按位异或运算(即 C++ 中的 ^ 符号)。答案对 取模。
输入格式
本题包含多组数据。第一行输入一个整数 ,表示数据组数。
接下来 行,每行输入两个整数 。
输出格式
输出共 $T$ 行,每行一个整数,表示每组询问的答案。2
2 2
3 3
6
12
2
4 8
8 9
144
420
提示
#### 样例解释第一个样例第一组数据:
$\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}$
数据范围
| 子任务 | 特殊性质 | 分值 | |
|---|---|---|---|
| 无 | |||
| A | |||
| 无 |
- 特殊性质 A:保证 ,,其中 。
对于 的数据,保证 ,。 标签: P9223|O2优化