当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

5448:Marisa’s Cake

题目描述
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!
输入解释
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.
输出解释
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)
输入样例
2
4
0 0
1 0
1 1
0 2
5
1 1
3 1
3 2
2 3
1 2
输出样例
9
50
来自杭电HDUOJ的附加信息
Recommend hujie

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-5448

最后修改于 2020-10-25T23:22:45+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
3000/2000MS(Java/Others) 131072/131072K(Java/Others)