Quantum Moochanics
Time limit2sMemory limit1024 MB
Given alternating mootrinos and antimootrinos on a line that reverse direction at each observation, find the observation number when each particle disappears.
- Level
Medium7 of 10
- Topics
- Simulation, Binary search, Math
- Solved
- No attempts yet
Problem
In her free time, Bessie likes to dabble in experimental physics. She recently discovered a pair of new subatomic particles, mootrinos and antimootrinos. Like ordinary matter-antimatter pairs, a mootrino and an antimootrino annihilate each other and disappear when they meet. What makes these particles unusual is that each one reverses its direction of motion, keeping the same speed, whenever Bessie looks at them.
For her latest experiment, Bessie has placed an even number () of these particles in a line. The line starts with a mootrino on the left and then alternates between the two types of particles. The -th particle is at position (). Mootrinos initially move right, and antimootrinos initially move left. The -th particle moves at a constant speed of units per second ().
Bessie makes observations at the following times. The first observation is 1 second after the start of the experiment. Each later observation comes 2 seconds after the previous one, then 3 seconds after that, and so on. In general, the -th observation comes seconds after the -th observation. During each observation, Bessie notes which particles have disappeared.
The experiment may take an extremely long time, so Bessie wants to simulate its results first. Given the setup, determine the observation number at which Bessie sees each particle disappear. It may be shown that all particles eventually disappear.
Input
Each input contains () independent test cases.
Each test case consists of three lines. The first line contains . The second line contains . The third line contains .
The sum of all does not exceed .
Output
For each test case, output the observation number for each particle's disappearance, separated by spaces.