CYCLOTRON
Participants in the camp of the 18th Hellenic Student Programming Contest (EPY 2005-06) visited the new Cyclotron for Elementary Particle Acceleration (CEPA) in Thessaloniki. This accelerator includes chambers for particle entry. At the entrance of each chamber, particles receive energy (where is the chamber number). During their trajectory to the next chamber, the particles spend energy equivalent to a potential barrier that they must "overcome". If , the particle will reach the next chamber (), where it will receive energy . Therefore, the total energy of the particle in chamber (assuming it entered at chamber ) will be: ( ) + .
You are asked to develop a program in one of the IOI languages that determines the first (with the smallest number) chamber from which, if the particle enters, it will complete a full circular trajectory within the accelerator.
INPUT DATA
The file cyclotron.in on the first line contains an integer indicating the number of entry chambers , where: (). In the next lines, two integers and separated by a space () are given. The first number on each line, (), provides the energy (in ) provided to the particle upon entry into the chamber, and the second number, (), gives the energy spent by the particle until the next chamber.
OUTPUT DATA
The file cyclotron.out consists of an integer corresponding to the chamber number from which the particle must start in order to complete a full circular trajectory within the accelerator. If there is no suitable entry chamber, the number 0
is returned.
Example of Input - Output Data
STDIN (cyclotron.in)
10
50 100
120 100
90 100
140 100
90 90
90 90
90 90
90 90
90 90
90 90
STDOUT (cyclotron.out)
2
Maximum execution time for each test: 4 sec.
Comments