z-paintball
Little Z became a member of a paintball club. As a new member of the club, he first has to show his skills to the "secret paintball committee". He was given a gun that can fire a bouncy balls, which do not lose any energy while traveling through the air. Also when the ball hits a wall, it bounces without losing any energy. When the ball bounces, the velocity of the ball parallel to the wall stays the same, and the velocity perpendicular to the wall changes its direction (by 180 degrees), but keeps its magnitude.
The practice room is a rectangular anti-gravity room - so that the bouncy ball never loses its height. The width and the height of the room are a and b, and have an opening of width d at the bottom. The ball is fired parallel to the ground so it always stays at the same altitude. If the ball hits an edge of the room it will bounce right back. The ball is always fired so that it enters the room through the middle of the opening at the bottom of the room.
The next line will contain an integer [
] - the position of the center of the opening from the left wall, and d - the width of the oppening.
Finally, the third line will contain an integer e - the x-coordinate distance of the gun from the center of the opening at the time when the ball is fired, then one letter "L" or "R", representing whether the gun is e to the left or e to the right, and finally an integer f - the y-coordinate distance of the gun from the opening. See the explanation of the example for details.Limits: 2 <= a <= 1000; 1 <= b <= 1000, 1 <= c < a, 1 <= d < 1000. The value of d is chosen so that the opening is not touching the (left and right) walls.
0 <= e <= 100 000; 1 <= f <= 100 000.
[c]6 6
3 1
1 L 1
Output:
3Explanation: The ball is fired from the position marked with p. The ball enters the room exactly through the middle of the opening. First it bounces out of the left wall (1). Then it bounces out of the top wall (2) and finally bounces out of the left wall (3). After that the ball will exit the room exactly through the middle of the opening.
Submit solution
Coming laterThe grading service will be connected in a later migration step. You can inspect the task and your previous results now.