A10077 | New Year and Cake
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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 $10^{9}+7$ .
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 $10^{9}+7$ .
输入格式
The first line of the input contains a single integer $n$ ( $4<=n<=500000$ ) — 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}|<=10^{9}$ ) — 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.
Each of the next $n$ lines contains two integers $x_{i}$ and $y_{i}$ ( $|x_{i}|,|y_{i}|<=10^{9}$ ) — 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.
输出格式
Print the sum of values of Limak's disappointment over all possible scenarios modulo $10^{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$ .
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted