#P6599. 「EZEC-2」异或
「EZEC-2」异或
Description
There are queries. In each query, you are given two positive integers .
You need to construct a positive integer sequence of length (indexed from to ), such that for all , we have .
Find the maximum value of:
To avoid the answer being too large, for each query, you only need to output this maximum value modulo .
Input Format
The first line contains an integer , representing the number of test cases.
Then from line to line , each line contains two integers , representing the maximum possible value of and the length of , respectively.
Output Format
Output lines, each containing one integer: the answer for the corresponding query modulo .
1
2 3
6
2
114 514
1919 180
8388223
16580700
Hint
Sample Explanation #1
When , if is any permutation of , the maximum value can be achieved, which is . It is easy to prove that the expression reaches its maximum in this case.
Constraints | Test Point ID | | | | | :----------: | :----------: | :----------: | :----------: | | | | | | | | | | | | | | | | | | | | |
For of the data, , , .
Hints
- "" is the bitwise XOR operator. If you do not know what bitwise XOR is, you can refer to here.
- Modulo is an operation. Taking modulo means assigning to the remainder when is divided by .
In C++ / Python, the modulo operator is%, and in Pascal it ismod. - is the summation symbol. If you do not know what means, you can refer to here.
- Please pay attention to the impact of input/output efficiency on your program.
Translated by ChatGPT 5
京公网安备 11011102002149号