Shooting Lasers
Time limit1.5sMemory limit1024 MB
Given sensors in a strip with mirror walls, find the launch angle from (0, 0) that lights the most sensors using fewer than K wall reflections.
Problem
A plane has width , is fixed at the bottom, and extends infinitely upward. Map the space onto a coordinate plane so that the lower-left corner is the point . The point units to the right and units up from is . Since the width is , the lines and are the two side walls.
A laser launcher sits at . Both side walls are mirrors, so when the laser hits a wall, it reflects with the angle of incidence equal to the angle of reflection. Due to a technical limitation, the launcher cannot be turned to a direction parallel or perpendicular to the walls.
On the plane there are distinct lattice points, and each has a sensor. When the laser passes exactly through a sensor's coordinates, the light bulb connected to that sensor turns on. Each reflection weakens the laser, so a laser that has reflected off a mirror or more times is not detected by any sensor.
Given and the sensor coordinates, find the maximum number of bulbs that can be lit at the same time by adjusting the firing angle of the launcher.
Input
The first line contains the number of sensors (), the wall width (), and the number of reflections () after which the laser is too weak to be detected.
From the second line through line , each line gives the coordinates of a sensor (, ). All sensors are on integer points, and no point is given twice.
Output
Print the maximum number of bulbs that can be lit at the same time with the launcher.