CF559D.Randomizer

省选/NOI-

通过率:0%

时间限制:2.50s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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 .

杰拉尔德厌倦了使用普通的六面骰子玩棋盘游戏,于是他买了一个名为“随机器(Randomizer)”的玩具。其工作方式如下:

随机器自带一个坐标平面,平面上绘制了一个严格凸多边形,该多边形称为基本多边形。当你摇动随机器时,它会从基本多边形的顶点中选取若干个顶点,构成某个非退化(即面积不为零)的凸多边形。本次摇动的结果(更准确地说,是摇动产生的结果)被定义为:所选多边形严格内部(即边界上的整点不计入)所含的整点个数。现在杰拉尔德想知道:摇动随机器的期望结果是多少?

在摇动过程中,随机器会考虑所有以基本多边形顶点为顶点的、可能的非退化凸多边形。假设有 kk 种这样的多边形,则随机器以等概率 1k\frac{1}{k} 选择其中每一种。

输入格式

The first line of the input contains a single integer n (3 ≤ n ≤ 100 000) — 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 ( - 109 ≤ x__i, y__i ≤ 109) — the coordinates of the i-th vertex of the polygon. The vertices are given in the counter-clockwise order.

输入的第一行包含一个整数 nn(3≤n≤100 0003 \leq n \leq 100\,000)—— 基本多边形的顶点数。

接下来的 nn 行包含基本多边形各顶点的坐标。其中第 ii 行包含两个整数 xix_i 和 yiy_i(−109≤xi,yi≤109-10^9 \leq x_i, y_i \leq 10^9)—— 表示多边形第 ii 个顶点的坐标。顶点按逆时针顺序给出。

输出格式

Print the sought expected value with absolute or relative error at most 10 - 9.

以绝对或相对误差不超过 10−910^{-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 .

如果一个多边形是凸的,且其任意三个顶点都不共线,则称该多边形为严格凸多边形。

假设一个随机变量分别以概率 p1,…,pnp_1, \dots, p_n 取值 x1,…,xnx_1, \dots, x_n。则该随机变量的期望值等于

输入解题思路,AI测评打分。不知道怎么写?

首页