CF293D.Ksusha and Square
省选/NOI-
通过率:0%
时间限制:4.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Ksusha is a vigorous mathematician. She is keen on absolutely incredible mathematical riddles.
Today Ksusha came across a convex polygon of non-zero area. She is now wondering: if she chooses a pair of distinct points uniformly among all integer points (points with integer coordinates) inside or on the border of the polygon and then draws a square with two opposite vertices lying in the chosen points, what will the expectation of this square's area be?
A pair of distinct points is chosen uniformly among all pairs of distinct points, located inside or on the border of the polygon. Pairs of points p, q (p ≠ q) and q, p are considered the same.
Help Ksusha! Count the required expectation.
库舒沙是一位充满活力的数学家,她热衷于解决那些令人难以置信的数学谜题。
今天,库舒沙遇到了一个面积非零的凸多边形。她现在思考这样一个问题:如果她在该多边形内部或边界上所有整点(即坐标均为整数的点)中,均匀随机地选取一对互异的点,然后以这对点为某正方形的一组对顶点作正方形,那么该正方形面积的期望值是多少?
所有位于多边形内部或边界上的互异点对被等概率选取;点对 p,q(其中 p=q)与 q,p 被视为同一对。
请帮助库舒沙!计算该期望值。
输入格式
The first line contains integer n (3 ≤ n ≤ 105) — the number of vertices of Ksusha's convex polygon. Next n lines contain the coordinates of the polygon vertices in clockwise or counterclockwise order. The i-th line contains integers x__i, y__i (|x__i|, |y__i| ≤ 106) — the coordinates of the vertex that goes i-th in that order.
第一行包含一个整数 $ n ( 3 \leq n \leq 10^5 $)——表示库苏沙的凸多边形的顶点数。接下来的 $ n $ 行按顺时针或逆时针顺序给出该多边形各顶点的坐标。第 $ i $ 行包含两个整数 $ x_i 、 y_i ( |x_i|, |y_i| \leq 10^6 $)——表示按该顺序排在第 $ i $ 位的顶点的坐标。
输出格式
Print a single real number — the required expected area.
The answer will be considered correct if its absolute and relative error doesn't exceed 10 - 6.
输出一个实数——所求的期望面积。
若答案的绝对误差和相对误差均不超过 10−6,则视为正确。
输入输出样例
输入#1
3 0 0 5 5 5 0
输出#1
4.6666666667
输入#2
4 -1 3 4 5 6 2 3 -5
输出#2
8.1583333333
输入#3
3 17 136 859 937 16 641
输出#3
66811.3704155169
输入解题思路,AI测评打分。不知道怎么写?