#P3476. [POI2008] TRO-Triangles

    ID: 2536 Type: RemoteJudge 2000ms 125MiB Tried: 0 Accepted: 0 Difficulty: 6 Uploaded By: Tags>计算几何2008POI深度优先搜索,DFS叉积

[POI2008] TRO-Triangles

题目描述

nn pairwise disjoint points in the plane are given (n3n\ge 3).

There are n(n1)(n2)6\dfrac{n(n-1)(n-2)}{6} triangles whose vertices are some pairwise different points among them (including degenerate triangles, i.e. ones whose vertices are collinear).

We want to calculate the sum of areas of all the triangles with vertices in the given points.

Those parts of the plane that belong to many triangles are to be calculated multiple times. We assume that the area of degenerate triangles (i.e. those with collinear vertices) is zero.

Write a programme that:

reads from the standard input the coordinates of the points in the plane, determines the sum of the areas of all the triangles with vertices in the given points, prints out the result to the standard output.

输入格式

In the first line of the standard input there is one integer nn (3n30003\le n\le 3000) denoting the number of selected points.

Each of the following nn lines contains two integers xix_i and yiy_i (0xi,yi1040\le x_i,y_i\le 10^4) separated by a single space and denoting the coordinates of the ithi^\mathrm{th} point (for i=1,2,,ni=1,2,\cdots,n).

No pair (ordered) of coordinates appears more than once.

输出格式

In the first and only line of the standard output there should be one real number equal to the sum of the areas of all the triangles with vertices in the given points. The outcome should be printed out with exactly one digit after dot and should not differ from the correct value by more than 0.10.1.

题目大意

给定平面上的一些点,求这些点能组成的所有三角形的面积之和。

5
0 0
1 2
0 2
1 0
1 1

7.0