#P10855. 【MX-X2-T4】「Cfz Round 4」Gcd with Xor
【MX-X2-T4】「Cfz Round 4」Gcd with Xor
Background
Original link: https://oier.team/problems/X2D。
Hey, if we could throw everything away,
Hey, if we could throw everything away.
Would living with a smile become easier?
Would living with a smile become easier?
Problem Description
Given two positive integers 。
Define $\displaystyle f(x)=\sum_{i=1}^x \gcd(i,i\oplus x)^k$。Compute 。Here, denotes the greatest common divisor of and , and denotes bitwise XOR, i.e. ^ in C++。
Since the answer may be very large, you only need to output the result modulo 。
Input Format
This problem has multiple test cases.
The first line contains an integer , indicating the number of test cases.
Then each test case follows. For each test case, input one line with two positive integers 。
Output Format
For each test case, output one line with one integer, representing the answer modulo 。
5
3 2
10 1
261 261
2333 2333
124218 998244353
17
134
28873779
470507314
428587718
Hint
[Sample Explanation]
For the -st test case:
。
。
。
。
[Constraints]
For all test cases, , , , 。
This problem uses bundled testdata.
Let denote the sum of within a single test point.
- Subtask 1 (10 points): 。
- Subtask 2 (12 points): 。
- Subtask 3 (15 points): 。
- Subtask 4 (45 points): 。
- Subtask 5 (18 points): no special constraints。
Translated by ChatGPT 5