luogu#P6034. Ryoku 与最初之人笔记
Ryoku 与最初之人笔记
Background
When Ryoku was reading the notes of the “First Person”, she found an interesting operation: . This operation takes two numbers as input and outputs one number. It works by converting the two input numbers into binary, then comparing each bit: if the bits are the same, that bit in the output is ; otherwise it is .
Below the notes about the operation, there is an exercise. Ryoku quickly got the answer, and she wants to test you.
Problem Description
Ryoku retold the problem to you: compute:
$$\sum_{a = 0}^n \sum_{b = a + 1}^n [a\equiv b\pmod {a \text{ xor } b}]$$That is, count the number of ordered pairs such that , where are non-negative integers not greater than , and .
Input Format
The input contains one integer .
Output Format
Output one integer, the value of the expression above, modulo .
2
2
42
274
Hint
[Sample 1 Explanation]
The pairs that satisfy the condition are: .
[Constraints]
For of the testdata, .
For of the testdata, .
For of the testdata, .
For of the testdata, .
Translated by ChatGPT 5