C. 「PEOI Rd1」异或(xor)

    Type: RemoteJudge 1000ms 128MiB

「PEOI Rd1」异或(xor)

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

题目描述

给定两个正整数 n,mn,m,求:

$$\sum_{i=1}^{n}\sum_{j=1}^{m}\left(i \oplus j\right)$$

其中,\oplus 表示按位异或运算(即 C++ 中的 ^ 符号)。答案对 998244353998244353 取模。

输入格式

本题包含多组数据。

第一行输入一个整数 TT,表示数据组数。

接下来 TT 行,每行输入两个整数 n,mn,m

输出格式

输出共 TT 行,每行一个整数,表示每组询问的答案。

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}$


数据范围

子任务 n,mn,m \leq 特殊性质 分值
11 10310^3 1010
22 10610^6 2020
33 101610^{16} A
44 5050
  • 特殊性质 A:保证 n=2p1n=2^p-1m=2q1m=2^q-1,其中 p,qZp,q\in\mathbb Z

对于 100%100\% 的数据,保证 1n,m10161 \leq n,m \leq 10^{16}1T501 \leq T \leq 50

初一期中考 竞赛组

Not Attended
Status
Done
Rule
IOI
Problem
4
Start at
2025-12-26 10:30
End at
2025-12-26 12:30
Duration
2 hour(s)
Host
Partic.
16