CF1879D Sum of XOR Functions
题目描述
给定一个长度为 $n$ 的非负整数数组 $a$。
你需要计算 $\sum_{l=1}^{n} \sum_{r=l}^{n} f(l, r) \cdot (r - l + 1)$ 的值,其中 $f(l, r)$ 表示 $a_l \oplus a_{l+1} \oplus \dots \oplus a_{r-1} \oplus a_r$(符号 $\oplus$ 表示按位异或运算)。
由于答案可能非常大,请输出其对 $998244353$ 取模后的结果。
输入格式
第一行包含一个整数 $n$($1 \le n \le 3 \cdot 10^5$),表示数组 $a$ 的长度。
第二行包含 $n$ 个整数 $a_1, a_2, \dots, a_n$($0 \le a_i \le 10^9$)。
输出格式
输出一个整数,表示 $\sum_{l=1}^{n} \sum_{r=l}^{n} f(l, r) \cdot (r - l + 1)$ 对 $998244353$ 取模后的值。
说明/提示
在第一个样例中,答案等于 $f(1, 1) + 2 \cdot f(1, 2) + 3 \cdot f(1, 3) + f(2, 2) + 2 \cdot f(2, 3) + f(3, 3) = 1 + 2 \cdot 2 + 3 \cdot 0 + 3 + 2 \cdot 1 + 2 = 12$。
由 ChatGPT 4.1 翻译