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.
思路:只要知道锐角三角形三边的关系a^2+b^2>c^2即可
#include <stdio.h> #include <string.h> #include <math.h> int main() { double a[2][105],x,y,z; int i,j,k,ans,n,t,flag1,flag2,flag3; scanf("%d",&t); while(t--) { scanf("%d",&n); for(i = 0;i<n;i++) scanf("%lf%lf",&a[0][i],&a[1][i]); ans = 0; for(i = 0;i<n-2;i++) { for(j = i+1;j<n-1;j++) { for(k = j+1;k<n;k++) { flag1 = flag2 = flag3 = 0; x = sqrt((a[0][i]-a[0][j])*(a[0][i]-a[0][j])+(a[1][i]-a[1][j])*(a[1][i]-a[1][j])); y = sqrt((a[0][i]-a[0][k])*(a[0][i]-a[0][k])+(a[1][i]-a[1][k])*(a[1][i]-a[1][k])); z = sqrt((a[0][k]-a[0][j])*(a[0][k]-a[0][j])+(a[1][k]-a[1][j])*(a[1][k]-a[1][j])); if(x*x+y*y>z*z) flag1 = 1; if(y*y+z*z>x*x) flag2 = 1; if(x*x+z*z>y*y) flag3 = 1; if(flag1 && flag2 && flag3) ans++; } } } printf("%d\n",ans); } return 0; }