问题 F: The Mountain

内存限制:128 MB 时间限制:1.000 S
评测方式:文本比较 命题人:
提交:235 解决:187

题目描述

All as we know, a mountain is a large landform that stretches above the surrounding land in a limited area. If we as the tourists take a picture of a distant mountain and print it out, the image on the surface of paper will be in the shape of a particular polygon. From mathematics angle we can describe the range of the mountain in the picture as a list of distinct points, denoted by (x1,y1) to (xn,yn). The first point is at the original point of the coordinate system and the last point is lying on the x-axis. All points else have positive y coordinates and incremental x coordinates. Specifically, all x coordinates satisfy 0 = x1 < x2 < x3 < ··· < xn. All y coordinates are positive except the first and the last points whose y coordinates are zeroes. The range of the mountain is the polygon whose boundary passes through points (x1,y1) to (xn,yn) in turn and goes back to the first point. In this problem, your task is to calculate the area of the range of a mountain in the picture. 
众所周知,山是一种大型陆地形态,它在有限的区域内高耸于周围的陆地之上。如果我们作为旅游者拍摄一座远处的山,并将其打印出来,纸张表面上的图像将呈现出一个特定的多边形形状。从数学的角度来看,我们可以将图片中山的范围描述为一组不同的点,表示为 $(x_1,y_1)$ 到 $(x_n,y_n)$。第一个点位于坐标系原点,最后一个点位于 x 轴上。除第一个和最后一个点之外的所有点的 y 坐标都是正数,而它们的 x 坐标递增。具体而言,所有 x 坐标满足 $0 = x_1 < x_2 < x_3 < ... < x_n$。所有 y 坐标都是正数,除了第一个和最后一个点的 y 坐标为零。山的范围是一个多边形,其边界依次通过点 $(x_1,y_1)$ 到 $(x_n,y_n)$,并回到第一个点。在这个问题中,你的任务是计算图片中山的范围的面积。

输入

The input has several test cases and the first line describes an integer t (1 ≤ t ≤ 20) which is the total number of cases. In each case, the first line provides the integer n (1 ≤ n ≤ 100) which is the number of points used to describe the range of a mountain. Following n lines describe all points and the i-th line contains two integers xi and yi (0 ≤ xi,yi ≤ 1000) indicating the coordinate of the i-th point. 
输入包含多个测试用例,设测试用例总数为 $t$,则第一行描述一个整数 $t$ $(1 \leq t \leq 20)$,表示测试用例的总数。在每个测试用例中,第一行给出一个整数 $n$ $(1 \leq n \leq 100)$,表示用于描述山的范围的点数。接下来的 $n$ 行描述所有的点,第 $i$ 行包含两个整数 $x_i$ 和 $y_i$ $(0 \leq x_i, y_i \leq 1000)$,表示第 $i$ 个点的坐标。

输出

For each test case, output the area in a line with the precision of 6 digits. 
对于每个测试用例,输出一个精度为 6 位小数的面积值。

样例输入 复制

3 
3 
0 0 
1 1
2 0
4 
0 0
5 10
10 15
15 0
5 
0 0 
3 7 
7 2 
9 10 
13 0

样例输出 复制

1.000000 
125.000000 
60.500000