#P5467. [PKUSC2018] PKUSC
[PKUSC2018] PKUSC
Description
Jiutiao Keliang is a girl who loves playing games.
Recently, she has been playing a hack-and-slash mowing game. There are enemies on the plane, and the coordinates of each enemy are . Keliang has a skill that allows her to draw a simple polygon with points on the plane, and eliminate all enemies that are strictly inside the polygon.
It is not hard to see that if she wants to eliminate enemies quickly, she can just draw a sufficiently large simple polygon. But that would make the game much less fun. So, Keliang decides to add some randomness to the game.
Keliang casually draws a simple polygon with points on the plane. Next, she plans to randomly choose a number according to the uniform distribution on (you can think of it as choosing with equal probability), and rotate this simple polygon counterclockwise around the origin by an angle of (in radians).
Now Keliang gives you the coordinates of every point and the polygon. Your task is to help Keliang compute the expected number of enemies she can eliminate after a random rotation.
Input Format
The first line contains four integers .
The next lines each contain two integers , describing the coordinates of an enemy.
The next lines each contain two integers , describing each vertex of the simple polygon in counterclockwise order.
Output Format
Output one line with one number representing the expected value, rounded to five digits after the decimal point. It is guaranteed that, before rounding, the -th digit after the decimal point will not be or for all testdata.
4 4
0 0
1 0
-1 -1
0 1
0 0
1 0
1 1
0 1
0.50000
Hint
Sample Explanation
If you are not very familiar with probability and expectation, here are some hints:
- Let be the probability that after rotation, exactly enemies can be eliminated. Then the expectation is .
- One way to compute is: among all rotation angles in the range , the angles for which exactly enemies are eliminated after rotation form intervals (whether endpoints are open or closed does not matter). Then .
In this problem: the intervals where enemies can be eliminated are , and the intervals where enemy can be eliminated are . Therefore, . So the answer is .
Constraints
For of the data, .
For another of the data, the chosen simple polygon is a convex polygon.
For of the data, .
Translated by ChatGPT 5
京公网安备 11011102002149号