F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Marisa¡¯s Cake

Time Limit: 3000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 376    Accepted Submission(s): 220


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)
 

Sample Input
2 4 0 0 1 0 1 1 0 2 5 1 1 3 1 3 2 2 3 1 2
 

Sample Output
9 50
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-12-11 21:39:19, Gzip enabled