A15632 | Koxia and Sequence
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Mari has three integers $n$ , $x$ , and $y$ .
Call an array $a$ of $n$ non-negative integers good if it satisfies the following conditions:
- $a_1+a_2+\ldots+a_n=x$ , and
- $a_1 \, | \, a_2 \, | \, \ldots \, | \, a_n=y$ , where $|$ denotes the [bitwise OR operation](https://en.wikipedia.org/wiki/Bitwise_operation#OR).
The score of a good array is the value of $a_1 \oplus a_2 \oplus \ldots \oplus a_n$ , where $\oplus$ denotes the [bitwise XOR operation](https://en.wikipedia.org/wiki/Bitwise_operation#XOR).
Koxia wants you to find the total bitwise XOR of the scores of all good arrays. If there are no good arrays, output $0$ instead.
Call an array $a$ of $n$ non-negative integers good if it satisfies the following conditions:
- $a_1+a_2+\ldots+a_n=x$ , and
- $a_1 \, | \, a_2 \, | \, \ldots \, | \, a_n=y$ , where $|$ denotes the [bitwise OR operation](https://en.wikipedia.org/wiki/Bitwise_operation#OR).
The score of a good array is the value of $a_1 \oplus a_2 \oplus \ldots \oplus a_n$ , where $\oplus$ denotes the [bitwise XOR operation](https://en.wikipedia.org/wiki/Bitwise_operation#XOR).
Koxia wants you to find the total bitwise XOR of the scores of all good arrays. If there are no good arrays, output $0$ instead.
输入格式
The first line of input contains three integers $n$ , $x$ and $y$ ( $1 \leq n < 2^{40}$ , $0 \leq x < 2^{60}$ , $0 \leq y < 2^{20}$ ).
输出格式
Output a single integer — the total bitwise XOR of the scores of all good arrays.
输入输出样例
输入 #1
3 5 3
输出 #1
2
输入 #2
100 0 100
输出 #2
0
输入 #3
79877974817 749875791743978 982783
输出 #3
64
In the first test case, there are $12$ good arrays totally as follows.
- $[0,2,3]$ , $[0,3,2]$ , $[2,0,3]$ , $[2,3,0]$ , $[3,0,2]$ and $[3,2,0]$ — the score is $0 \oplus 2 \oplus 3 = 1$ ;
- $[1, 2, 2]$ , $[2, 1, 2]$ and $[2, 2, 1]$ — the score is $1 \oplus 2 \oplus 2 = 1$ ;
- $[1, 1, 3]$ , $[1, 3, 1]$ and $[3, 1, 1]$ — the score is $1 \oplus 1 \oplus 3 = 3$ .
Therefore, the total bitwise xor of the scores is $\underbrace{1 \oplus \ldots \oplus 1}_{9\text{ times}} \oplus 3 \oplus 3 \oplus 3 = 2$ .
In the second test case, there are no good sequences. The output should be $0$ .
- $[0,2,3]$ , $[0,3,2]$ , $[2,0,3]$ , $[2,3,0]$ , $[3,0,2]$ and $[3,2,0]$ — the score is $0 \oplus 2 \oplus 3 = 1$ ;
- $[1, 2, 2]$ , $[2, 1, 2]$ and $[2, 2, 1]$ — the score is $1 \oplus 2 \oplus 2 = 1$ ;
- $[1, 1, 3]$ , $[1, 3, 1]$ and $[3, 1, 1]$ — the score is $1 \oplus 1 \oplus 3 = 3$ .
Therefore, the total bitwise xor of the scores is $\underbrace{1 \oplus \ldots \oplus 1}_{9\text{ times}} \oplus 3 \oplus 3 \oplus 3 = 2$ .
In the second test case, there are no good sequences. The output should be $0$ .
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted