# FZU2110 Star【计算几何】

Overpower often go to the playground with classmates. They play and chat on the playground. One day, there are a lot of stars in the sky. Suddenly, one of Overpower’s classmates ask him: “How many acute triangles whose inner angles are less than 90 degrees (regarding stars as points) can be found? Assuming all the stars are in the same plane”. Please help him to solve this problem.
Input

The first line of the input contains an integer T (T≤10), indicating the number of test cases.

For each test case:

The first line contains one integer n (1≤n≤100), the number of stars.

The next n lines each contains two integers x and y (0≤|x|, |y|≤1,000,000) indicate the points, all the points are distinct.

Output
For each test case, output an integer indicating the total number of different acute triangles.
Sample Input
1
3
0 0
10 0
5 1000

Sample Output
1

emmm题目的意思还要学会转换

A^2 + B^2 < C^2 就是锐角三角形

double getAngle(Point p1, Point p2, Point p3)
{
double angle = 0.0;
Point va, vb;
va.x = p2.x - p1.x;
va.y = p2.y - p1.y;
vb.x = p3.x - p1.x;
vb.y = p3.y - p1.y;

double productValue = va.x * vb.x + va.y * vb.y;
double vaVal = sqrt(va.x * va.x + va.y * va.y);
double vbVal = sqrt(vb.x * vb.x + vb.y * vb.y);
double cosVal = productValue / (vaVal * vbVal);

if(cosVal < -1 && cosVal > -2){
cosVal = -1;
}
else if(cosVal > 1 && cosVal < 2){
cosVal = 1;
}

angle = acos(cosVal) * 180 / PI;
return angle;
}

#include <iostream>
#include <algorithm>
#include <cstring>

#include <cstdio>

#include <cmath>

using namespace std;
#define PI 3.1415926
#define EPS 1.0e-6

struct Point {
Point(){}
Point(double x, double y):x(x), y(y){}
double x,y;

};
struct Line{
Point st, ed;
};

double getAngle(Point p1, Point p2, Point p3)
{
double angle = 0.0;
Point va, vb;
va.x = p2.x - p1.x;
va.y = p2.y - p1.y;
vb.x = p3.x - p1.x;
vb.y = p3.y - p1.y;

double productValue = va.x * vb.x + va.y * vb.y;
double vaVal = sqrt(va.x * va.x + va.y * va.y);
double vbVal = sqrt(vb.x * vb.x + vb.y * vb.y);
double cosVal = productValue / (vaVal * vbVal);

if(cosVal < -1 && cosVal > -2){
cosVal = -1;
}
else if(cosVal > 1 && cosVal < 2){
cosVal = 1;
}

angle = acos(cosVal) * 180 / PI;
return angle;
}

int dblcmp(double r) {

if(fabs(r)<EPS) return 0;

return r>0?1:-1;

}

double cross(Point p1, Point p2, Point p3, Point p4)
{
return (p2.x - p1.x) * (p4.y - p3.y) - (p2.y - p1.y) * (p4.x - p3.x);
}

double area(Point p1, Point p2, Point p3)
{
return cross(p1, p2, p1, p3);
}

double farea(Point p1, Point p2, Point p3)
{
return fabs(area(p1, p2, p3));
}

bool meet(Point p1, Point p2, Point p3, Point p4)
{
return max(min(p1.x, p2.x), min(p3.x, p4.x)) <= min(max(p1.x, p2.x), max(p3.x, p4.x))
&& max(min(p1.y, p2.y), min(p3.y, p4.y)) <= min(max(p1.y, p2.y), max(p3.y, p4.y))
&& dblcmp(cross(p3, p2, p3, p4) * cross(p3, p4, p3, p1)) >= 0
&& dblcmp(cross(p1, p4, p1, p2) * cross(p1, p2, p1, p3)) >= 0;
}

Point inter(Point p1, Point p2, Point p3, Point p4)
{
double k = farea(p1, p2, p3) / farea(p1, p2, p4);
return Point((p3.x + k * p4.x) / (1 + k), (p3.y + k * p4.y) / (1 + k));
}

bool sharpTri(Point p1, Point p2, Point p3)
{
double edge[3];
edge[0] = (p1.x - p2.x) * (p1.x - p2.x) + (p1.y - p2.y) * (p1.y - p2.y);
edge[1] = (p1.x - p3.x) * (p1.x - p3.x) + (p1.y - p3.y) * (p1.y - p3.y);
edge[2] = (p2.x - p3.x) * (p2.x - p3.x) + (p2.y - p3.y) * (p2.y - p3.y);

sort(edge, edge + 3);
if(edge[2] < edge[1] + edge[0] + EPS){
return true;
}
else return false;
}

int n;
Point star[105];

int main() {

int t;
cin>>t;
while(t--){
scanf("%d", &n);
for(int i = 0; i < n; i++){
scanf("%lf%lf", &star[i].x, &star[i].y);
}
int cnt = 0;
for(int i = 0; i < n - 2; i++){
for(int j = i + 1; j < n - 1; j++){
for(int k = j + 1; k < n; k++){
//cout<<getAngle(star[i], star[j], star[k])<<endl;
if(sharpTri(star[i], star[j], star[k])) cnt++;
}
}
}
cout<<cnt<<endl;
}

return 0;

}