Billiards
Time limit1sMemory limit128 MB
Decide which of six table pockets a frictionless bouncing ball reaches, or report that it never falls in.
- Level
Medium7 of 10
- Topics
- Math, Number theory, Simulation, Implementation
- Solved
- No attempts yet
Problem
On a Friday evening, Bajtazar and his friends head to a club for a game of billiards. As usual at such gatherings, an argument breaks out between Bajtazar and Bitol. Bajtazar claims that Bitol's strategy is pointless, because the ball he strikes has no chance of dropping into a pocket. Bitol insists that if he hit the ball hard enough, it would eventually fall into some pocket. Help settle their argument: write a program that decides whether the ball really would fall into a pocket, and if so, which one.
Your program should:
- read the dimensions of the billiard table, the starting position of the struck ball, and the vector describing how the ball moves after the strike,
- determine which pocket the ball falls into, or determine that it never falls into any pocket,
- print the result.
Input
The one and only line contains six integers , , , , , separated by single spaces:
- , : the dimensions of the table, with and even,
- , : the ball's starting position, with and ,
- , : the motion vector, with .
The table is long and wide. Pockets sit at the four corners and at the midpoints of the two sides of length . For example, a table of size has pockets at , , , , , and . The ball never leaves the table and moves without friction; every bounce off a cushion follows the rule that the angle of incidence equals the angle of reflection. The ball drops into a pocket exactly when it reaches the point where that pocket is located.
Output
Print a single line: the name of the pocket the ball drops into, or the word NIE if that never happens. The pocket names are:
GL: the pocket atGP: the pocket atGS: the pocket atDL: the pocket atDP: the pocket atDS: the pocket at
Hint
