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;
}