Sunlight Hours (Small)
Time limit5sMemory limit512 MB
Compute the share of building height that gets at least H hours of direct sun as the sun travels a semicircular path past blocking buildings.
- Level
Medium6 of 10
- Topics
- Geometry, Binary search
- Solved
- No attempts yet
Problem
A is about to get married and has enough money for a home, but picking one with enough sunlight is hard. The city is full of buildings, and many homes sit in another building's shadow for much of the day. Work out how many homes in the city meet A's requirement.
The sun rises at at 6 in the morning, travels a semicircular path of radius at a constant speed, and sets at 12 hours later at 6 in the evening. The center of the semicircle is the origin on the ground.

The vertical lines in the picture are buildings, and the blue region is the interval of time when the sun reaches the home at the very bottom of the middle building.
The city has buildings. Building is the vertical segment from to and has zero thickness. No two buildings stand at the same coordinate.
Every building holds infinitely many homes of the same form, and no two homes in one building sit at the same height. The homes are spread evenly along the height of the building from the ground to the top, and the number of homes per unit of height is the same in every building. The share of homes that satisfy a condition is therefore the total length of the heights that satisfy it, divided by the sum of all building heights .
The home at height in building is the point , where . The sun reaches that home at a given moment when the segment joining the home and the sun is not blocked by another building. That is, for every building with , if the segment crosses the line , the crossing point must be higher than . The home's own building has zero thickness, so it never blocks the sun.
Find the share of homes that get at least hours of sun in a day.
Input
The first line holds the number of test cases .
Each test case is given in this form.
N R H
X1 Y1
...
XN YN
On the first line, is the number of buildings, is the radius of the semicircle the sun travels, and is the smallest number of sunlit hours A accepts. Each of the next lines holds the coordinate and the height of one building. Coordinates are measured from the center of the semicircle.
Constraints
- The values are distinct within one test case.
- Every number in the input is an integer.
Output
For each test case print one line in the form Case #x: y. Here is the test case number starting from 1, and is the share of homes that get at least hours of sun in a day. Print rounded to seven digits after the decimal point, with all seven digits shown.