Codeforces Beta Round 83 (Div. 1 Only)
E
Darts
Codeforces
2700
原题
← D→
翻译中…

The night after the graduation ceremony graduate students of German University in Cairo (GUC) are playing darts. As there's no real dart board available, the photographs of members of the GUC upper management are being used.

翻译中…

So, $*n*$ rectangular photos are placed on the wall. They can overlap arbitrary and even coincide. The photos are not necessarily placed horizontally or vertically, they could also be rotated before being pinned to the wall.

翻译中…

The score of one dart throw is simply the number of photos the dart went through.

翻译中…

Fatma has made a throw but her score was not recorded. She only remembers that she did make it into at least one photo.

翻译中…

Assuming that the probability distribution of the throw is equal across the whole wall, what would be the expectation of Fatma's score?

翻译中…

Input

翻译中…

The first line of input contains integer $*n*$ ($1 ≤ *n* ≤ 500$) — the number of photos on the wall. Then follow $*n*$ lines describing the photos, each containing $8$ single-space-separated integers (coordinates of $4$ vertices): $*x*_{1}$, $*y*_{1}$, $*x*_{2}$, $*y*_{2}$, $*x*_{3}$, $*y*_{3}$, $*x*_{4}$, $*y*_{4}$. Each photo is a rectangle with a nonzero area. The coordinates are integers, not exceeding $10^{4}$ by absolute value. The coordinates of the rectangle are given in either clockwise or counterclockwise order.

翻译中…

Output

翻译中…

Print the expected score of the throw. The answer will be accepted if it has absolute or relative error not exceeding $10^{ - 6}$.

翻译中…

样例

Input #1
1
0 0 0 2 2 2 2 0
Output #1
1.0000000000
InputCopy OutputCopy
Input #2
1
-1 0 0 1 1 0 0 -1
Output #2
1.0000000000
InputCopy OutputCopy
Input #3
4
0 0 0 1 3 1 3 0
0 0 0 3 1 3 1 0
3 3 2 3 2 0 3 0
3 3 3 2 0 2 0 3
Output #3
1.5000000000
InputCopy OutputCopy
Input #4
2
-1 0 0 1 1 0 0 -1
0 0 1 1 2 0 1 -1
Output #4
1.1428571429
InputCopy OutputCopy
题目信息
题号
107E
时间限制
5 s
内存限制
256 MB
标签
计算几何
概率论

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。