#abc365e. E - Xor Sigma Problem
E - Xor Sigma Problem
Score : points
问题陈述
给定一个长度为 的整数序列 。找出以下表达式的值:
$\displaystyle \sum_{i=1}^{N-1}\sum_{j=i+1}^N (A_i \oplus A_{i+1}\oplus \ldots \oplus A_j)$。
关于按位异或的说明:非负整数 和 的按位异或,记作 ,定义如下:
- 在 的二进制表示中,()位置的数字是 当且仅当在 和 的二进制表示中 位置的数字中恰好有一个是 ;否则,它是 。
例如,(二进制:)。 一般来说, 个整数 的按位异或定义为 $(\cdots ((p_1 \oplus p_2) \oplus p_3) \oplus \cdots \oplus p_k)$。可以证明这与 的顺序无关。
以上为大语言模型 kimi 翻译,仅供参考。
Problem Statement
You are given an integer sequence of length . Find the value of the following expression:
$\displaystyle \sum_{i=1}^{N-1}\sum_{j=i+1}^N (A_i \oplus A_{i+1}\oplus \ldots \oplus A_j)$.
Notes on bitwise XOR The bitwise XOR of non-negative integers and , denoted as , is defined as follows:
- In the binary representation of , the digit at the () position is if and only if exactly one of the digits at the position in the binary representations of and is ; otherwise, it is .
For example, (in binary: ).
In general, the bitwise XOR of integers is defined as $(\cdots ((p_1 \oplus p_2) \oplus p_3) \oplus \cdots \oplus p_k)$. It can be proved that this is independent of the order of .
Constraints
- All input values are integers.
Input
The input is given from Standard Input in the following format:
Output
Print the answer.
Sample Input 1
3
1 3 2
Sample Output 1
3
, , and , so the answer is .
Sample Input 2
7
2 5 6 5 2 1 7
Sample Output 2
83