CF611G.New Year and Cake

省选/NOI-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

Limak is a little polar bear. According to some old traditions, his bear family prepared a New Year cake. And Limak likes cakes.

As you may know, a New Year cake is a strictly convex polygon with n vertices.

Parents won't allow Limak to eat more than half of a cake because he would get sick. After some thinking they decided to cut a cake along one of n·(n - 3) / 2 diagonals. Then Limak will get a non-greater piece.

Limak understands rules but he won't be happy if the second piece happens to be much bigger. Limak's disappointment will be equal to the difference between pieces' areas, multiplied by two. It can be proved that it will be integer for the given constraints.

There are n·(n - 3) / 2 possible scenarios. Consider them all and find the sum of values of Limak's disappointment, modulo 109 + 7.

Limak 是一只小北极熊。根据一些古老的传统,他的熊家族准备了一个新年蛋糕。而 Limak 喜欢蛋糕。

如你所知,一个新年蛋糕是一个具有 nn 个顶点的严格凸多边形。

由于 Limak 吃得太多会生病,父母不允许他吃掉超过蛋糕一半的部分。经过一番考虑,他们决定沿该多边形的某一条对角线将蛋糕切开。随后,Limak 将得到其中面积不大于另一半的那一块。

Limak 理解这些规则,但如果另一块面积远大于他所得的那一块,他仍会不开心。Limak 的“失望值”定义为两块面积之差乘以 2。可以证明:在本题给定的约束条件下,该失望值必为整数。

共有 n⋅(n−3)/2n \cdot (n - 3) / 2 种可能的切割方案(即多边形的对角线总数)。请考虑所有这些方案,并求出所有情况下 Limak 失望值的总和,结果对 109+710^9 + 7 取模。

输入格式

The first line of the input contains a single integer n (4 ≤ n ≤ 500 000) — the number of vertices in the polygon denoting the cake.

Each of the next n lines contains two integers x__i and y__i (|x__i|, |y__i| ≤ 109) — coordinates of the i-th point.

It's guaranteed that all points are distinct, polygon is strictly convex and points are given in the clockwise order.

输入的第一行包含一个整数 nn(4≤n≤500 0004 \leq n \leq 500\,000),表示表示蛋糕的多边形的顶点数。

接下来的 nn 行中,每行包含两个整数 xix_i 和 yiy_i(∣xi∣,∣yi∣≤109|x_i|, |y_i| \leq 10^9),表示第 ii 个顶点的坐标。

保证所有顶点互不相同,该多边形为严格凸多边形,且各顶点按顺时针顺序给出。

输出格式

Print the sum of values of Limak's disappointment over all possible scenarios modulo 109 + 7.

输出 Limak 在所有可能情形下的失望值之和对 109+710^9 + 7 取模的结果。

输入输出样例

  • 输入#1

    5
    2 4
    2 7
    5 7
    5 4
    3 -2

    输出#1

    90
  • 输入#2

    4
    -1000000000 -5000000
    0 1234567
    1 1
    -5 -100000000

    输出#2

    525185196
  • 输入#3

    8
    -10 0
    -6 6
    0 10
    6 6
    10 0
    6 -6
    0 -10
    -6 -6

    输出#3

    5216

说明/提示

In the first sample possible values of Limak's disappointment are 0, 18, 18, 24, 30.

在第一个样例中,Limak 的失望值可能为 0, 18, 18, 24, 300,\,18,\,18,\,24,\,30。

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

首页