Hide

Problem F
Safari Zones

/problems/safarizones/file/statement/en/img-0001.jpg
Midnight Form Lycanroc

The researchers at the Safari Zone are trying to introduce Midnight Lycanrocs into their preserve. However, due to their aggressive tendencies, the researchers need to find out how much space to allocate for the Lycanrocs.

So far, the researchers have determined that Lycanrocs view their territory as a square, centered around their nest. Additionally, this square is always oriented towards the position of the moon at the time when the Lycanrocs were evolved.

To test territorial behavior, they have placed $2$ Lycanrocs in close proximity, to observe whether a clash occurs.

To properly analyze the data, the researchers need to know how much territory overlap is present in each setup. Can you help the researchers by calculating the proportion of overlapping territory for each Lycanroc?

Input

The input starts with one line containing one integer $s$, representing the side length of both territories. The side length is bounded to $1 \leq s \leq 1\, 000$ steps.

Then follows two lines, each containing $3$ integers $x$, $y$, and $\theta $.

$(x,y)$ represents the position of the Lycanroc nest, $-500 \leq x,y \leq 500$.

$\theta $ represents the orientation of the territories. This can be interpreted as the rotation of the square in degrees in the counterclockwise direction, $0 \leq \theta < 90$.

Output

Output one line containing the proportion of the intersection area to the area of the first square. Your answer will be considered correct as long as it doesn’t exceed a relative or absolute error of $10^{-2}$.

\includegraphics[width=0.9\textwidth ]{examples.png}
Figure 1: Illustration of all Sample Cases. The area of overlap is given in red.
Sample Input 1 Sample Output 1
1
0 0 0
0 0 0
1
Sample Input 2 Sample Output 2
2
0 0 0
0 1 0
0.5
Sample Input 3 Sample Output 3
3
0 0 0
0 0 45
0.82843

Please log in to submit a solution to this problem

Log in