问题描述:
给你n个坐标,看能构成锐角三角形的最大数目
代码:
#include <iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
struct Node
{
int x,y;
};
bool ischeck(Node a,Node b,Node c)
{
bool flag=false;
double s[3]={0};
s[0]=(a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y);///ab
s[1]=(a.x-c.x)*(a.x-c.x)+(a.y-c.y)*(a.y-c.y);///ac
s[2]=(b.x-c.x)*(b.x-c.x)+(b.y-c.y)*(b.y-c.y);///bc
sort(s,s+3);
if(s[0]+s[1]>s[2])
if(s[0]*s[0]+s[1]*s[1]>s[2]*s[2])
flag=true;
return flag;
}
int main()
{
int t,n,cnt;
scanf("%d",&t);
while(t--)
{
Node node[101];
cnt=0;
scanf("%d",&n);
for(int i=0; i<n; i++)
scanf("%d%d",&node[i].x,&node[i].y);
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++)
if(ischeck(node [i],node [j],node [k]))
cnt++;
cout<<cnt<<endl;
}
return 0;
}