Star
Description
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
130 010 05 1000
Sample Output
1
//题意:给你三个或者三个以上的坐标点,问任意三点构成的三角形有多少个内角是不大于90度的。
//思路:用枚举,把点一一例举出来,然后求锐角三角形。
根据三角形定义来求:较小的两条边平方和大于较大的一条边的平和就是锐角三角形。
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
struct ma
{
float x,y;
}line[102];
float div(ma a,ma b)
{
return sqrt((b.x-a.x)*(b.x-a.x)+(b.y-a.y)*(b.y-a.y));
}
int main()
{
int T,n,i,j,k;
float la,lb,lc;
while(scanf("%d",&T)!=EOF)
{
while(T--)
{
scanf("%d",&n);
int s=0;
for(i=0;i<n;i++)
scanf("%f%f",&line[i].x,&line[i].y);
for(i=0;i<n;i++)
for(j=i+1;j<n;j++)
for(k=j+1;k<n;k++)
{
la=div(line[i],line[j]);
lb=div(line[i],line[k]);
lc=div(line[j],line[k]);
if((la*la-(lb*lb+lc*lc)<0)&&(lb*lb-(la*la+lc*lc)<0)&&(lc*lc-(la*la+lb*lb)<0)) s++;
}
printf("%d\n",s);
}
}
return 0;
}