#Lutece0575. Interesting Marble
Interesting Marble
Migrated from Lutece 575 Interesting Marble
All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.
Description
Marble (also called "Hitting the bricks") is a famous video game with a long history. During the game, the player is required to control a single ball to hit the bricks above. The ball will rebound when touching the wall or the paddle the player controls at the bottom. If the player's paddle misses the ball's rebound, the game will over.
Lvba developed a new version of the game. The new game is played inside a square. There are no bricks, but a lot of balls. Those balls will move simultaneously at the beginning of the game. All the balls' horizontal and vertical velocity is equal to or , so there are four different moving directions in total. The player has a paddle at the bottom, if the paddle misses a ball's rebound, that ball will fall off and disappear.
The goal of the new game is to find an initial position of the paddle at the bottom, and a strategy to move the paddle horizontally, to make sure that maximum number of balls will not fall off the bottom and will move inside the square forever. The moving speed of the paddle is also equal to .
You may assume the balls are small enough to be regarded as points, and the paddle is a segment of length . The ball will rebound when touching the paddle or the walls. The balls' initial positions are strictly inside the square. You should notice that the balls will not affect each other when their positions coincide.
Now given the initial position of the balls, and their moving directions, please find the maximum number of the balls that will be kept moving forever.
Input
The first line of the input will be an integer indicating the number of cases. ()
For each case, the first line contains two integers: (), (), representing the number of the balls, and the side length of the square. Then lines follow, each in the format of x y vx vy
.
is the position of the balls. We set the original point at the lower left corner of the square, the bottom as -axis, and the left wall as -axis.
is the ball's velocity at the beginning of the game, in which and equals or .
Output
For each case, you need to output two lines. Print Case #k: S
first in a single line, in which represents the case number which starts from , is the maximum number of balls the player can keep.
Samples
2
3 4
1 1 1 1
2 1 1 1
3 3 -1 1
2 4
1 1 -1 -1
2 1 -1 -1
Case #1: 3
Case #2: 2
Note
- It is not allowed to move the paddle out of the square.
- The ball rebounds according to the physical law, for example, if a ball touches the left side of the wall with speed , its speed will turn to ; Moreover, if a ball touches the lower left corner with speed , its speed will turn to .
- The picture shows the second case in sample input.
Resources
10th UESTC Programming Contest Final