#abc278h. Ex - make 1
Ex - make 1
Score : points
问题描述
一个由非负整数组成的序列 被称为好序列,如果满足以下条件:
- 存在一个非空(不一定连续)的子序列 ,使得 中所有元素按位异或的结果为 。
给定一个空序列 和 张卡片,每张卡片上分别写有从 到 的一个整数。
你需要重复执行以下操作,直到 变成一个好序列:
- 自由选择一张卡片,并将其上所写的整数追加到 的末尾。然后吃掉这张卡片。(一旦被吃掉,卡片就不能再被选择了。)
在经过这些操作后,最终长度为 的序列 有多少种可能?请计算结果对 取模后的数量。
什么是按位异或(bitwise XOR)?两个非负整数 和 的按位 运算,记作 ,定义如下:
- 当 表示为二进制时,第 位最低位()为 当且仅当 和 的第 位最低位中恰好有一个是 ,否则为 。
例如:(以二进制表示:)。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
A sequence of non-negative integers is said to be a good sequence if:
- there exists a non-empty (not necessarily contiguous) subsequence of such that the bitwise XOR of all elements in is .
There are an empty sequence , and cards with each of the integers between and written on them.
You repeat the following operation until becomes a good sequence:
- You freely choose a card and append the integer written on it to the tail of . Then, you eat the card. (Once eaten, the card cannot be chosen anymore.)
How many sequences of length can be the final after the operations? Find the count modulo .
What is bitwise XOR? The bitwise of non-negative integers and , , is defined as follows.
- When is written in binary, the -th lowest bit () is if exactly one of the -th lowest bits of and is , and otherwise.
For instance, (in binary: ).
Constraints
- and are integers.
Input
The input is given from Standard Input in the following format:
Output
Print the answer.
Sample Input 1
2 2
Sample Output 1
5
The following five sequences of length can be the final after the operations.
Sample Input 2
2022 1119
Sample Output 2
293184537
Sample Input 3
200000 10000000
Sample Output 3
383948354
update @ 2024/3/10 11:43:45