Particle
Time limit1sMemory limit256 MB
Decide whether a point bouncing off rectangle walls with fixed velocity reaches target A before target B or neither.
- Level
Medium7 of 10
- Topics
- Number theory, Geometry
- Solved
- No attempts yet
Problem
A particle moves inside a W by H rectangle with constant velocity (a,b). It reflects off walls like light on a mirror, and at a corner it reverses direction. Starting from (x0,y0), decide whether it reaches A=(x1,y1) before B=(x2,y2), the opposite order, or neither ever.
Input
The first line has T test cases. Each test case is one line with W, H, x0, y0, x1, y1, x2, y2, a, b.
Output
Print A if A is reached first, B if B is reached first, or O if neither is reached.