Marisa’s Cake

TimeLimit: 3000/2000 MS (Java/Others)  MemoryLimit: 131072/131072 K (Java/Others)
64-bit integer IO format:%I64d
未提交 | 登录后收藏
Problem Description
Today is Marisa’s birthday and she is given a cake the shape of a convex polygon of $n$ vertices. Furthermore, all the $n$ vertices are all going to be on integer points of the Cartesian coordinate system. Marisa asks her friend Reimu to randomly cut off some vertices of the cake. The set of vertices chosen to be cut off has size at most $n - 3$, and all possible choices have the same probability to be picked up. In order to remove all chosen vertices, Reimu might cut the cake several times. Since Reimu is a perfectionist, she will always cut the cake from one vertex to another. Hence, Reimu’s cutting will not generate vertices which are not in the original polygon.

Marisa wants to know the expected size of the cake she might get, and because you are madly in love with her, you decided to do anything she wants for her! You take out your laptop and are ready to calculate the expected size for Marisa. However, Marisa is bad with fractions. She wants to make sure the answer she gets is always an integer. To do that, she would like you to multiply the answer with the total number of possible cakes there are. Unfortunately, that still doesn’t guarantee the answer be an integer. An additional 2 must also be multiplied into the answer as well. For example, let $A = (0, 0), B = (1, 0), C = (1, 1), D = (0, 2)$ and $ABCD$ is the shape of Marisa’s birthday cake. There are $5$ possible pieces $ABCD, ABC, BCD, CDA, DAB$ that Marisa might get, and the corresponding area of these convex polygons are $\frac{3}{2}, \frac{1}{2}, \frac{1}{2}, 1, 1$ respectively. The expected size of the cake that Marisa might get is $(\frac{3}{2} + \frac{1}{2} + \frac{1}{2} + 1 + 1) ÷ 5 = \frac{9}{10}$ , and what you should tell Marisa $\frac{9}{10} × 5 × 2 = 9$. Calculate the answer for Marisa and who knows, maybe she would love you back!
Input
The first line on the input contains an integer $T (T \leq 10)$. There will be $T$ test cases. The first line of each test case contains an integer $n (3 \leq n \leq 100000)$ indicating the number of vertices of the convex polygon. The $i-th$ of the following $n$ lines contains two integers $x_i$ and $y_i (0 \leq x, y \leq 10^9)$ separated by a blank. $(x_i, y_i)$ is the $i-th$ vertex of the convex polygon, and $(x_1, y_1), . . . , (x_n, y_n)$ will be in counterclockwise order.
Output
For each test case, output a number as the answer. In case the answer is greater than $1000000006$, please modulo the answer with $1000000007$. (You might figure out by now that Marisa is not good at dealing with large numbers either)
SampleInput
2
4
0 0
1 0
1 1
0 2
5
1 1
3 1
3 2
2 3
1 2
SampleOutput
9
50
Submit
题目统计信息详细
总AC数3
通过人数3
尝试人数4
总提交量5
AC率60.00%
AC该题后可以添加标签
贴完标签可以获得20ACB。
并且可以获得本题所有提交代码查看权限。
点击标题可以显示标签。
如果你还没认真思考过这题,请不要查看标签
如果您已经通过了该题,请务为该题贴上标签

T^T Online Judge

[BUG反馈] [FAQ] [闽ICP备17026590号-1]
当前版本:3.24 系统时间: