#P1161. Find the Lone Lit Lamp
Find the Lone Lit Lamp
Find the Lone Lit Lamp
On an infinitely long road, there is an infinite row of street lamps numbered \(1,2,3,\dots\). Each lamp can be either on or off. Initially, all lamps are off. When you press the switch of a lamp, its state toggles: if it was off it becomes on, and if it was on it becomes off.
Xiao Ming performs \(n\) operations. In each operation, he is given a real number \(a\) and a positive integer \(t\). Then he toggles 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, ]
where \(\lfloor x \rfloor\) is the floor of \(x\) (i.e. the greatest integer less than or equal to \(x\)). After the \(n\) operations, exactly one lamp remains on. Your task is to determine the index of that lamp.
inputFormat
The first line contains an integer \(n\) representing the number of operations. Each of the following \(n\) lines contains a real number \(a\) and a positive integer \(t\), separated by a space, describing one operation.
outputFormat
Output a single integer representing the index of the lamp that is still on after all operations.
sample
1
2.3 1
2