409395: GYM103496 H Halcon Collider
Description
Try to guess the problem from the following gif: https://imgur.com/xtk06Dt
The Physics Departments in the Philippines' top universities decided that it was high time that the Philippines catch up with other countries' research facilities, so that Filipino physicists could also be at the frontier of new theoretical discoveries. Thus, they have teamed up to create the Great Halcon Collider, a particle accelerator constructed beneath the mountains of the Mindoro provinces.
Alice was fortunate enough to have been selected by her school to be a student delegate who will be one of the first to tour the brand new facilities. However, the head scientists at the Great Halcon Collider were concerned about letting untrained teenagers onto their multi-billion peso facilities. Thus, they decided to administer the following test, and would only allow entry to the students who answer it correctly.
A positron particle, modeled as a point, begins in the bottom-left corner of a box with horizontal width $$$w$$$ and vertical height $$$h$$$. The particle moves continuously in a straight line at a constant velocity. Initially, the particle has a horizontal velocity of $$$x$$$ units per second, and a vertical velocity of $$$y$$$ units per second, where $$$x$$$ and $$$y$$$ are positive integers.
- What is the total distance traveled by the positron before vanishing?
- How many times did the positron bounce off a side of the box?
- Which of the four corners did the positron vanish at?
Alice really wants to see the Great Halcon Collider, so she's asked for your help!
InputInput begins with a single line, containing a single integer $$$t$$$.
Then, $$$t$$$ lines follow, each describing a test case. Each line contains the four space-separated integers $$$w$$$, $$$h$$$, $$$x$$$, $$$y$$$, respectively, for that test case.
OutputFor each query, output three lines, answering each of the scientists' questions.
- First, output a real number, the total distance (in units) traveled by the positron before vanishing.
- Then, output an integer, the number of times the positron bounced off a side of the box.
- Finally, output a string denoting which corner the positron vanished at. This should be one of TL, TR, BL, BR, which correspond to the top-left, top-right, bottom-left, and bottom-right corner, respectively.
$$$$$$\begin{align*}
&\begin{array}{|l|} \hline \text{Constraints For All Subtasks} \\ \hline 1 \leq t \leq 1000 \\ \text{$1 \leq w, h, x, y \leq 1000$ for all test cases.} \\ \hline \end{array}\\
&\begin{array}{|c|c|l|} \hline \text{Subtask} & \text{Points} & \text{Constraints} \\ \hline 1 & \mathbf{30} & \text{$x = y = 1$ for all test cases.} \\ \hline 2 & \mathbf{30} & \text{$w = h = 1$ for all test cases.} \\ \hline 3 & \mathbf{30} & \text{$1 \leq w, h, x, y \leq 10$ for all test cases.} \\ \hline 4 & \mathbf{10} & \text{No further constraints.} \\ \hline \end{array}\\
\end{align*}$$$$$$
1 1 1 1 1Output
1.414213562373 0 TRInput
3 1 2 1 1 1 3 2 4 4 3 5 2Output
2.828427124746 1 TL 6.708203932499 3 BR 64.621977685614 21 BRNote
The positron travels as follows in the first sample input.
The positron travels as follows in the first test case of the second sample input.
The positron travels as follows in the second test case of the second sample input.
An animated gif of the positron's trajectory in the third test case of the second sample input has been uploaded here: https://imgur.com/xtk06Dt. This is the same gif shown at the beginning of the problem statement.