#abc356d. D - Masked Popcount
D - Masked Popcount
Score : points
问题陈述
给定整数 和 ,计算和 ,模 。
这里, 表示按位 操作。
什么是按位 操作?非负整数 和 之间的按位 操作的结果 定义如下:
-
是满足以下条件的唯一非负整数,对于所有非负整数 :
-
如果 的二进制表示中的 位和 的二进制表示中的 位都是 ,那么 的二进制表示中的 位是 。
-
否则, 的二进制表示中的 位是 。
例如, 和 ,所以 。什么是 ? 表示 的二进制表示中 的数量。 例如,,所以 。
以上为大语言模型 kimi 翻译,仅供参考。
Problem Statement
Given integers and , compute the sum , modulo .
Here, represents the bitwise operation.
What is the bitwise operation? The result of the bitwise operation between non-negative integers and is defined as follows:
-
is the unique non-negative integer that satisfies the following conditions for all non-negative integers :
-
If the place in the binary representation of and the place in the binary representation of are both , then the place in the binary representation of is .
-
Otherwise, the place in the binary representation of is .
For example, and , so . What is ? represents the number of s in the binary representation of .
For example, , so .
Constraints
- is an integer between and , inclusive.
- is an integer between and , inclusive.
Input
The input is given from Standard Input in the following format:
Output
Print the answer as an integer.
Sample Input 1
4 3
Sample Output 1
4
The sum of these values is .
Sample Input 2
0 0
Sample Output 2
0
It is possible that or .
Sample Input 3
1152921504606846975 1152921504606846975
Sample Output 3
499791890
Remember to compute the result modulo .