|
While taking a walk through the woods, a group of Foxen have come upon a |
|
curious sight — a row of **N** wooden poles sticking straight up out of the |
|
ground! Who placed them there, and why? The Foxen have no clue. |
|
|
|
Looking at the poles from the side, they can be modeled as vertical line |
|
segments rising upwards from a number line (which represents the ground), with |
|
the _i_th pole at distinct integral position **Pi** and having a real-valued |
|
height of **Hi**. |
|
|
|
One of the Foxen, Ozy, is fascinated by the shadows being cast on the ground |
|
by the poles. The sun is shining down on the poles from some point very high |
|
up in the sky, resulting in infinitely many rays of light descending towards |
|
the number line at all possible positions along it, but all travelling in some |
|
uniform direction. Each ray of light stops travelling as soon as it comes into |
|
contact with either a pole or the ground. Any point on the ground which is |
|
incapable of being reached by rays of light (because they would get blocked by |
|
at least one pole before reaching that point) is considered to be covered in |
|
shadows. |
|
|
|
The sunlight's direction can be described by a real value _a_, with absolute |
|
value no larger than 80, where _a_ is the signed angle difference (in degrees) |
|
between the rays' direction and a vector pointing directly downwards. As an |
|
example, let's imagine that there's a single pole at position 50 and with a |
|
height of 100. If _a_ = 45, then sunlight is shining diagonally down and to |
|
the right, meaning that the pole obstructs rays of light from being able to |
|
reach any points on the ground in the interval [50, 150], effectively casting |
|
a shadow with length 100 to the right. If _a_ = -45, then sunlight is shining |
|
diagonally down and to the left, causing the pole to cast a shadow with 100 to |
|
the left instead (over the interval [-50, 50]). If _a_ = 0, then sunlight is |
|
shining directly downwards onto the ground, resulting in the pole not casting |
|
any shadow. |
|
|
|
Ozy is planning on returning by himself tomorrow in order to observe the poles |
|
again, but he doesn't know at what time of day he'll be able to make the trip. |
|
He does at least have it narrowed down to being within some interval of time, |
|
during which he knows that the sunlight's direction _a_ will range from **A** |
|
and **B**, inclusive. Given that the sunlight's direction _a_ will be a real |
|
number drawn uniformly at random from the interval [**A**, **B**] when Ozy |
|
visits the poles tomorrow, please help him predict the expected total length |
|
of ground which will be covered in shadows at that time. |
|
|
|
### Input |
|
|
|
Input begins with an integer **T**, the number of different sets of poles. For |
|
each set of poles, there is first a line containing the space-separated |
|
integers **N**, **A**, and **B**. Then **N** lines follow, the _i_th of which |
|
contains the integer **Pi** and the real number **Hi** separated by a space. |
|
The poles' heights are given with at most 4 digits after the decimal point. |
|
|
|
### Output |
|
|
|
For the _i_th set of poles, print a line containing "Case #**i**: " followed |
|
by a single real number, the expected length of ground which will be covered |
|
in shadows. Your output should have at most 10-6 absolute or relative error. |
|
|
|
### Constraints |
|
|
|
1 ≤ **T** ≤ 30 |
|
1 ≤ **N** ≤ 500,000 |
|
-80 ≤ **A** < **B** ≤ 80 |
|
0 ≤ **Pi** ≤ 1,000,000,000 |
|
1 ≤ **Hi** ≤ 1,000,000 |
|
The sum of **N** values across all **T** cases does not exceed 2,000,000. |
|
|
|
### Explanation of Sample |
|
|
|
In the first case, the sunlight's direction _a_ is drawn uniformly at random |
|
from the interval [44, 46]. As described above, the length of ground covered |
|
in shadows when _a_ = 45 is exactly 100. When _a_ = 44, the shadow's length is |
|
~96.57, and when _a_ = 46, its length is ~103.55. However, note that its |
|
expected length for this distribution of possible _a_ values is not equal to |
|
the average of those sample lengths. |
|
|
|
|