luogu#P10405. 「SMOI-R1」Queue
「SMOI-R1」Queue
Background
A check-in problem……
Problem Description
There is a queue with people. The -th person in the queue has ID .
Starting from the first person, a number is passed to the next person one by one, until it reaches person . The rule for passing the number to the next person is:
- The first person's number is .
- If this person's ID is odd, then the number passed to the next person is the current number bitwise AND with the next person's ID.
- If this person's ID is even, then the number passed to the next person is the current number bitwise XOR with the next person's ID.
Find the number passed to person . But computing just one case is too easy, so you need to handle cases.
Input Format
This problem has multiple test cases.
The first line contains an integer , the number of test cases.
For each test case:
There is only one number , representing the number of people in the queue.
Output Format
For each test case, output one number, which is the number passed to person .
3
1
5
10
1
5
8
Hint
Sample Explanation
For the second test case:
- The number passed from the first person to the next is .
- The number passed from the second person to the next is .
- The number passed from the third person to the next is .
- The number passed from the fourth person to the next is .
So the answer is .
Constraints
This problem uses bundled testdata.
| subtask ID | Score | ||
|---|---|---|---|
For of the testdata, it is guaranteed that and 。
Translated by ChatGPT 5