A9877 | Randomizer
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Gerald got tired of playing board games with the usual six-sided die, and he bought a toy called Randomizer. It functions as follows.
A Randomizer has its own coordinate plane on which a strictly convex polygon is painted, the polygon is called a basic polygon. If you shake a Randomizer, it draws some nondegenerate (i.e. having a non-zero area) convex polygon with vertices at some vertices of the basic polygon. The result of the roll (more precisely, the result of the shaking) is considered to be the number of points with integer coordinates, which were strictly inside (the points on the border are not considered) the selected polygon. Now Gerald is wondering: what is the expected result of shaking the Randomizer?
During the shaking the Randomizer considers all the possible non-degenerate convex polygons with vertices at the vertices of the basic polygon. Let's assume that there are $k$ versions of the polygons. Then the Randomizer chooses each of them with probability .
A Randomizer has its own coordinate plane on which a strictly convex polygon is painted, the polygon is called a basic polygon. If you shake a Randomizer, it draws some nondegenerate (i.e. having a non-zero area) convex polygon with vertices at some vertices of the basic polygon. The result of the roll (more precisely, the result of the shaking) is considered to be the number of points with integer coordinates, which were strictly inside (the points on the border are not considered) the selected polygon. Now Gerald is wondering: what is the expected result of shaking the Randomizer?
During the shaking the Randomizer considers all the possible non-degenerate convex polygons with vertices at the vertices of the basic polygon. Let's assume that there are $k$ versions of the polygons. Then the Randomizer chooses each of them with probability .
输入格式
The first line of the input contains a single integer $n$ ( $3<=n<=100000$ ) — the number of vertices of the basic polygon.
Next $n$ lines contain the coordinates of the vertices of the basic polygon. The $i$ -th of these lines contain two integers $x_{i}$ and $y_{i}$ ( $-10^{9}<=x_{i},y_{i}<=10^{9}$ ) — the coordinates of the $i$ -th vertex of the polygon. The vertices are given in the counter-clockwise order.
Next $n$ lines contain the coordinates of the vertices of the basic polygon. The $i$ -th of these lines contain two integers $x_{i}$ and $y_{i}$ ( $-10^{9}<=x_{i},y_{i}<=10^{9}$ ) — the coordinates of the $i$ -th vertex of the polygon. The vertices are given in the counter-clockwise order.
输出格式
Print the sought expected value with absolute or relative error at most $10^{-9}$ .
输入输出样例
输入 #1
4 0 0 2 0 2 2 0 2
输出 #1
0.2
输入 #2
5 0 0 2 0 2 2 1 3 0 2
输出 #2
0.8125
A polygon is called strictly convex if it is convex and no its vertices lie on the same line.
Let's assume that a random variable takes values $x_{1},...,x_{n}$ with probabilities $p_{1},...,p_{n}$ , correspondingly. Then the expected value of this variable equals to .
Let's assume that a random variable takes values $x_{1},...,x_{n}$ with probabilities $p_{1},...,p_{n}$ , correspondingly. Then the expected value of this variable equals to .
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted