#abc367g. G - Sum of (XOR^K or 0)
G - Sum of (XOR^K or 0)
Score : points
问题陈述
给定正整数 , , ,以及一个非负整数序列:。
对于一个非空非负整数序列 ,我们定义它的得分如下。
- 如果 的长度是 的倍数:
- 否则:
这里, 表示按位异或。
找出 的 个非空子序列的得分之和,对 取模。
什么是按位异或?非负整数 和 的按位异或,记作 ,定义如下:
- 在 的二进制表示中,位置 ()的数字是 ,如果 和 的二进制表示中恰好有一个在该位置有 ,否则是 。
例如,(二进制:)。 一般来说, 个整数 的异或定义为 $(\cdots ((p_1 \oplus p_2) \oplus p_3) \oplus \cdots \oplus p_k)$,可以证明这与 的顺序无关。
以上为大语言模型 kimi 翻译,仅供参考。
Problem Statement
You are given positive integers , , , and a sequence of non-negative integers: .
For a non-empty non-negative integer sequence , we define its score as follows.
- If the length of is a multiple of :
- Otherwise:
Here, represents the bitwise XOR.
Find the sum, modulo , of the scores of the non-empty subsequences of .
What is bitwise XOR? The bitwise XOR of non-negative integers and , denoted as , is defined as follows:
- In the binary representation of , the digit at position () is if exactly one of and has a in that position in their binary representations, and otherwise.
For example, (in binary: ).
In general, the XOR of integers is defined as $(\cdots ((p_1 \oplus p_2) \oplus p_3) \oplus \cdots \oplus p_k)$, and 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 2 2
1 2 3
Sample Output 1
14
Here are the scores of the non-empty subsequences of .
- :
- :
- :
- :
- :
- :
- :
Therefore, the sought sum is .
Sample Input 2
10 5 3
100 100 100 100 100 100 100 100 100 100
Sample Output 2
252000000
Sample Input 3
16 4 100
7053 3876 3178 8422 7802 5998 2334 6757 6889 6637 7365 9495 7848 9026 7312 6558
Sample Output 3
432440016