CF107E.Darts
省选/NOI-
通过率:0%
时间限制:5.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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?
毕业典礼后的夜晚,开罗德国大学(GUC)的研究生们正在玩飞镖游戏。由于没有真正的飞镖靶,他们便将GUC高层管理人员的照片用作靶子。
因此,共有 n 张矩形照片被贴在墙上。这些照片可以任意重叠,甚至完全重合。照片不一定水平或垂直放置,也可能在钉到墙上之前经过旋转。
一次飞镖投掷的得分即为该飞镖穿过的照片数量。
法特玛投出了一镖,但她的得分未被记录。她只记得自己这一镖至少命中了一张照片。
假设飞镖击中墙面上任意位置的概率是均匀分布的,那么法特玛此次投掷得分的期望值是多少?
输入格式
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 104 by absolute value. The coordinates of the rectangle are given in either clockwise or counterclockwise order.
输入的第一行包含一个整数 n(1≤n≤500)—— 墙上照片的数量。接下来是 n 行,每行描述一张照片,包含 8 个用单个空格分隔的整数(即矩形 4 个顶点的坐标):x1, y1, x2, y2, x3, y3, x4, y4。每张照片均为面积非零的矩形。所有坐标的绝对值不超过 104。矩形顶点坐标按顺时针或逆时针顺序给出。
输出格式
Print the expected score of the throw. The answer will be accepted if it has absolute or relative error not exceeding 10 - 6.
输出投掷的期望得分。只要答案的绝对或相对误差不超过 10−6,即视为正确。
输入输出样例
输入#1
1 0 0 0 2 2 2 2 0
输出#1
1.0000000000
输入#2
1 -1 0 0 1 1 0 0 -1
输出#2
1.0000000000
输入#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
输出#3
1.5000000000
输入#4
2 -1 0 0 1 1 0 0 -1 0 0 1 1 2 0 1 -1
输出#4
1.1428571429
输入解题思路,AI测评打分。不知道怎么写?