How Lader |
Lader is a game that is played in a regular hexagonal board (all sides equal, all angles are also equal). The game is much similar as pool game. But there is only one hole that is situated in the center of the hexagon. The position of the board is given by a 2D co-ordinate system. The top and bottom sides of the hexagon are parallel to x axis. The center of the hexagonal board is situated at (0,0).
You are trying to hit the ball B1 and the direction of hitting is from B1 to B2. After you have hit the ball B1, it starts reflecting on the walls of the hexagonal Lader board. The initial speed of the ball is given. When a ball hits a wall, its speed decreases by 1 unit/second. The ball stops when its' speed becomes 0 unit/second.
You have to determine the final speed of the ball when it falls through the hole. If the ball stops before reaching the hole, print `Stops'. In this problem assume the followings:
The picture on the right above shows the movements of a ball on a Lader board. The numbers written denote the order of appearance.
The first line of the input denotes T ( 1T150), the number of test cases to follow. Each test case consists of a 6 integers, s ( 0 < s < 150), x1, y1, x2, y2, r, t ( 1t500). Here, s denotes the length of sides of the hexagon centered at (0,0).
(x1, y1) and (x2, y2) denote the position of ball B1 and ball B2 respectively. The balls will be strictly inside the hexagonal board. r denotes the radius of the hole, centered at (0,0). The hole resides strictly inside the hexagonal board. t denotes the initial speed of the ball.
For each input, you have to print the case number first, followed by the terminal speed when it falls in the hole. If the ball stops before falling in the hole, print `Stops'.
4 80 10 0 20 0 5 200 51 7 4 0 9 5 1 55 -5 8 -6 7 8 104 12 1 0 0 -1 1 271
Case 1: 198 Case 2: Stops Case 3: 99
Problemsetter: Anna Fariha
Special Thanks: Md. Mahbubul Hasan