#D11651. kun Likes To Play Darts
kun Likes To Play Darts
kun Likes To Play Darts
Background
The kindergarten attached to the University of Aizu is a kindergarten where children who love programming gather. Yu, one of the kindergarten children, loves darts as much as programming. Yu-kun was addicted to darts recently, but he got tired of ordinary darts, so he decided to make his own darts board.
See darts for darts.
Problem
The contents of the darts that Yu-kun thought about are as follows.
The infinitely wide darts board has several polygons with scores. The player has only one darts arrow. The player throws an arrow and stabs the arrow into one of the polygons to get the score written there. If you stab it in any other way, you will not get any points.
Yu-kun decided where to throw the arrow, but it doesn't always stick exactly. The darts board is a two-dimensional plane, and the position Yu-kun is aiming for is a point (cx, cy). The place where the arrow thrown by Yu-kun sticks is selected with a uniform probability from any point included in the circle with radius r centered on the point (cx, cy). The coordinates of the exposed points do not have to be integers.
Since the information on the darts board, the position (cx, cy) that Yu-kun aims at, and the radius r are given, answer the expected value of the score that Yu-kun can get.
Constraints
The input satisfies the following conditions.
- All inputs are given as integers
- 1 ≤ n ≤ 50
- 0 ≤ cx, cy, x, y ≤ 1000
- 1 ≤ r ≤ 100
- 3 ≤ p ≤ 10
- 1 ≤ score ≤ 100
- Polygon vertices are given in such an order that they visit adjacent vertices clockwise or counterclockwise.
- The sides of a polygon do not have anything in common with the sides of another polygon
- A polygon does not contain another polygon
- If the arrow sticks on the side of the polygon, no score will be given.
Input
n cx cy r Information on the 0th polygon Information on the first polygon ... Information on the (n-1) th polygon
n is the number of polygons on the darts board. Polygonal information is given in the following format.
p score x0 y0 x1 y1 ... x (p-1) y (p-1)
p represents the number of vertices of the polygon, and score represents the score written on the polygon. Each line segment of the polygon is a line segment connecting the vertices of (xi, yi) and (xi + 1, yi + 1) (i <p-1), and (xp-1, yp-1) and (x0, It is a line segment connecting the vertices of y0).
Output
Output the expected value of the score that Yu-kun can get in one line. Any number of digits after the decimal point may be output. However, the error in the answer must not exceed 0.000001 (10-6).
Examples
Input
1 2 2 1 4 1 0 0 2 0 2 2 0 2
Output
0.2500000000
Input
1 2 2 1 4 1 0 0 5 0 5 5 0 5
Output
1.0000000000
Input
4 3 3 2 3 1 1 1 3 3 1 5 4 2 2 0 5 0 4 2 3 2 3 3 4 3 6 1 6 5 4 4 3 4 4 4 5 6 2 6
Output
1.0574955319
Input
1 10 10 1 4 10 0 0 1 0 1 1 0 1
Output
0.0000000000
inputFormat
input satisfies the following conditions.
- All inputs are given as integers
- 1 ≤ n ≤ 50
- 0 ≤ cx, cy, x, y ≤ 1000
- 1 ≤ r ≤ 100
- 3 ≤ p ≤ 10
- 1 ≤ score ≤ 100
- Polygon vertices are given in such an order that they visit adjacent vertices clockwise or counterclockwise.
- The sides of a polygon do not have anything in common with the sides of another polygon
- A polygon does not contain another polygon
- If the arrow sticks on the side of the polygon, no score will be given.
Input
n cx cy r Information on the 0th polygon Information on the first polygon ... Information on the (n-1) th polygon
n is the number of polygons on the darts board. Polygonal information is given in the following format.
p score x0 y0 x1 y1 ... x (p-1) y (p-1)
p represents the number of vertices of the polygon, and score represents the score written on the polygon. Each line segment of the polygon is a line segment connecting the vertices of (xi, yi) and (xi + 1, yi + 1) (i <p-1), and (xp-1, yp-1) and (x0, It is a line segment connecting the vertices of y0).
outputFormat
Output
Output the expected value of the score that Yu-kun can get in one line. Any number of digits after the decimal point may be output. However, the error in the answer must not exceed 0.000001 (10-6).
Examples
Input
1 2 2 1 4 1 0 0 2 0 2 2 0 2
Output
0.2500000000
Input
1 2 2 1 4 1 0 0 5 0 5 5 0 5
Output
1.0000000000
Input
4 3 3 2 3 1 1 1 3 3 1 5 4 2 2 0 5 0 4 2 3 2 3 3 4 3 6 1 6 5 4 4 3 4 4 4 5 6 2 6
Output
1.0574955319
Input
1 10 10 1 4 10 0 0 1 0 1 1 0 1
Output
0.0000000000
样例
1 2 2 1
4 1
0 0
5 0
5 5
0 5
1.0000000000