#abc261e. E - Many Operations
E - Many Operations
Score : points
问题陈述
我们有一个变量 和 种改变 值的操作。操作 表示为整数对 ,操作如下:
- 如果 ,则将 的值替换为 ;
- 如果 ,则将 的值替换为 ;
- 如果 ,则将 的值替换为 。
用 的值初始化 并按顺序执行以下程序:
- 执行操作 ,然后打印 的结果值。
- 接下来,按顺序执行操作 ,然后打印 的值。
- 接下来,按顺序执行操作 ,然后打印 的值。
- 接下来,按顺序执行操作 ,然后打印 的值。
是什么?
非负整数 和 的 定义如下:
- 当 用二进制表示时, 位()上的数字如果 和 该位上的数字都是 ,则为 ,否则为 。
- 当 用二进制表示时, 位()上的数字如果 和 该位上至少有一个数字是 ,则为 ,否则为 。
- 当 用二进制表示时, 位()上的数字如果 和 该位上恰好有一个数字是 ,则为 ,否则为 。
例如,,,。
约束条件
- 输入中的所有值都是整数。
输入
输入从标准输入按照以下格式给出:
输出
按照问题陈述中的指定打印 行。
示例输入 1
3 10
3 3
2 5
1 12
示例输出 1
9
15
12
变量 的初始值为 。
- 操作 将 改为 。
- 接下来,操作 将 改为 ,然后操作 将其改为 。
- 接下来,操作 将 改为 ,然后操作 将其改为 ,接着操作 将其改为 。
示例输入 2
9 12
1 1
2 2
3 3
1 4
2 5
3 6
1 7
2 8
3 9
示例输出 2
0
2
1
0
5
3
3
11
2
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
We have a variable and kinds of operations that change the value of . Operation is represented as a pair of integers , and is the following operation:
- if , it replaces the value of with ;
- if , it replaces the value of with ;
- if , it replaces the value of with .
Initialize with the value of and execute the following procedures in order:
- Perform Operation , and then print the resulting value of .
- Next, perform Operation in this order, and then print the value of .
- Next, perform Operation in this order, and then print the value of .
- Next, perform Operation in this order, and then print the value of .
What are ?
The of non-negative integers and are defined as follows:
- When is written in base two, the digit in the 's place () is if both of the digits in that place of and are , and otherwise.
- When is written in base two, the digit in the 's place () is if at least one of the digits in that place of and is , and otherwise.
- When is written in base two, the digit in the 's place () is if exactly one of the digits in that place of and is , and otherwise.
For example, , , and .
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print lines, as specified in the Problem Statement.
Sample Input 1
3 10
3 3
2 5
1 12
Sample Output 1
9
15
12
The initial value of is .
- Operation changes to .
- Next, Operation changes to , and then Operation changes it to .
- Next, Operation changes to , and then Operation changes it to , and then Operation changes it to .
Sample Input 2
9 12
1 1
2 2
3 3
1 4
2 5
3 6
1 7
2 8
3 9
Sample Output 2
0
2
1
0
5
3
3
11
2
update @ 2024/3/10 11:04:30