#P1161. 开灯
开灯
Description
On an infinitely long road, there is an infinite row of street lamps, numbered .
Each lamp has two possible states: on or off. If you press the switch of a lamp once, its state toggles. If it was on, it turns off. If it was off, it turns on.
Initially, all lamps are off. Each time, Xiao Ming can perform the following operation:
Specify two numbers, ( is a real number, is a positive integer). Press once the switches of the lamps numbered $\lfloor a \rfloor, \lfloor 2 \times a \rfloor, \lfloor 3 \times a \rfloor, \dots, \lfloor t \times a \rfloor$. Here denotes the integer part of the real number .
After Xiao Ming has performed such operations, he suddenly discovers that exactly one lamp is on. He wants to know the index of this lamp, but it is too far away for him to read the number.
Fortunately, Xiao Ming still remembers the previous operations. He turns to you for help. Can you compute the index of the lamp that is on?
Input Format
The first line contains a positive integer , the number of operations.
The next lines each contain two numbers, . Here is a real number with exactly digits after the decimal point, and is a positive integer.
Output Format
Output a single positive integer: the index of the lamp that is on.
3
1.618034 13
2.618034 7
1.000000 21
20
Hint
Let .
- For 30% of the testdata, .
- For 80% of the testdata, .
- For 100% of the testdata, .
- For 100% of the testdata, , , .
It is guaranteed by the testdata that after operations, there is exactly one lamp that is on, so you do not need to handle invalid cases. Also, for all , the maximum value of does not exceed .
Translated by ChatGPT 5
京公网安备 11011102002149号