The Heung Shing Observatory has recently discovered a new hurricane approaching Heung Shing!
The world can be viewed as an infinite 2D Cartesian plane, and Heung Shing is located at coordinates $$$(H_x, H_y)$$$. The hurricane is currently located at coordinates $$$(C_x, C_y)$$$. It is predicted to move along a straight line that forms an angle of $$$D$$$ degrees counterclockwise with the positive x-axis, however, the angle formed by the actual trajectory may be different due to a multitude of factors – it can be any real value between $$$D - U$$$ and $$$D + U$$$ degrees with uniform probability. When the hurricane comes within a 1 unit radius (inclusive) of Heung Shing, measured in Euclidean distance, a Hurricane Signal is issued.
Consider the two sample scenarios shown in Figures 1 and 2. In both figures, Heung Shing is at point $$$H$$$ and the hurricane is currently at point $$$C$$$. The predicted trajectory of the hurricane is indicated by the green arrow. The actual trajectory of the hurricane must be within the sector formed by the red lines.
![]() | ![]() |
| Figure 1: | Figure 2: |
| $$$H = (3, 2), C = (2, 1), D = 45^\circ, U = 75^\circ$$$ | $$$H = (-1, 3), C = (1, 1), D = 210^\circ, U = 15^\circ$$$ |
A Hurricane Signal is issued when the hurricane enters the blue circle. In Figure 1, the Hurricane Signal may or may not be issued in the future depending on its actual trajectory. In Figure 2, the Hurricane Signal is never issued.
Charlie is now interested in finding the probability that the hurricane will trigger a Hurricane Signal, either at its current position or somewhere along its future trajectory. Help Charlie find the answer!
The first line consists of two integers $$$H_x$$$ and $$$H_y$$$ $$$(-1000 \leq H_x, H_y \leq 1000)$$$, the coordinates of Heung Shing.
The second line consists of two integers $$$C_x$$$ and $$$C_y$$$ $$$(-1000 \leq C_x, C_y \leq 1000)$$$, the coordinates of the current position of the hurricane.
The third line consists of an integer $$$D$$$ $$$(0 \leq D \lt 360)$$$ and an integer $$$U$$$ $$$(0 \lt U \lt 90)$$$, the angle (in degrees, counterclockwise) formed by the predicted trajectory and the positive x-axis, and the maximum deviation (in degrees) of the prediction.
Output a decimal number, the probability of a Hurricane Signal being issued. Your answer is considered correct if the absolute or relative error does not exceed $$$10^{-6}$$$.
Formally, let your answer be $$$x$$$ and the correct answer be $$$y$$$. Your answer is accepted if and only if $$$\frac{|x-y|}{\max(1,|y|)} \leq 10^{-6}$$$.
3 22 145 75
0.6
-1 32 1210 15
0
-1 34 -2120 12
0.213754265
See Figure 1 for an illustration of the first sample. The angle of the hurricane's path relative to the positive x-axis can be any value between $$$-30^\circ$$$ and $$$120^\circ$$$ with uniform probability. Heung Shing will issue the Hurricane Signal if this angle is between $$$0^\circ$$$ and $$$90^\circ$$$. Therefore the required probability is $$$\frac{90}{150} = 0.6$$$.
See Figure 2 for an illustration of the second sample. The angle of the hurricane's path relative to the positive x-axis can be any value between $$$195^\circ$$$ and $$$225^\circ$$$ with equal probability. The hurricane will always be more than 1 unit away from Heung Shing.
| Название |
|---|


