Musical Cords
Time limit120sMemory limit1024 MB
Given N points on a circle, each with a fixed cord length, find the K longest cords, where a cord's length is the two point lengths plus the chord between them.
Statement
Lauren is trying to play the most beautiful notes possible using a harp. The harp is a circle with a radius of centimeters. To play a note, a cord must be attached to the harp so that it connects two different attachment points on the perimeter of the circle. Lauren then plucks this cord to play a note.
There are attachment points on the perimeter of the harp where a cord can be attached. The -th attachment point is nanodegrees clockwise from the rightmost point of the perimeter, where a nanodegree is degrees.
The attachment points do not all use the same technology. The -th attachment point requires centimeters of cord for fixing. A cord fixed between two different attachment points and is exactly centimeters long, where is the length of the chord between points and , that is, the Euclidean distance between the two points.
Lauren thinks notes sound better when they come from longer cords. What are the longest cords that can be used with Lauren's harp?
Input
The first line contains the number of test cases . Each test case starts with a line containing three integers , , and : the number of attachment points, the radius of the harp in centimeters, and the number of cord lengths to report. The next lines each contain two integers and , the position in nanodegrees clockwise from the rightmost point and the cord length in centimeters needed at the -th attachment point.
Output
For each test case, output one line in the form Case #x: y1 y2 ... yK, where is the test case number starting from 1, and is the -th value in the sorted (non-increasing) list of all cord lengths. Each is correct if it is within an absolute or relative error of of the correct answer.
Limits
- .
- in at most 10 cases.
- in all cases where .
- .
- .
- for all .
- .
Hint
Cords between different pairs of points may cross each other, since Lauren plays only one note at a time.