A8871 | Ksusha and Square
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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.
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.
输入格式
The first line contains integer $n$ $(3<=n<=10^{5})$ — 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}|<=10^{6})$ — the coordinates of the vertex that goes $i$ -th in that order.
输出格式
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}$ .
The answer will be considered correct if its absolute and relative error doesn't exceed $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
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted