标签:
Description
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
Sample Input
1 3 0 0 10 0 5 1000
Sample Output
1
求锐角三角形的个数;
数学结论 : 锐角三角形 任意边满足 a^2<b^2+c^2 ;
AC代码:
#include"algorithm"
#include"iostream"
#include"cstring"
#include"cstdlib"
#include"cstdio"
#include"string"
#include"vector"
#include"stack"
#include"queue"
#include"cmath"
#include"map"
using namespace std;
typedef long long LL ;
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define FK(x) cout<<"["<<x<<"]\n"
#define memset(x,y) memset(x,y,sizeof(x))
#define memcpy(x,y) memcpy(x,y,sizeof(x))
#define bigfor(T) for(int qq=1;qq<= T ;qq++)
struct Star {
LL x;
LL y;
} st[200];
bool cmp(LL a,LL b) {
return a>b;
}
bool check(int i,int j,int k) {
LL s[3];
s[0]=(st[i].x-st[j].x)*(st[i].x-st[j].x)+(st[i].y-st[j].y)*(st[i].y-st[j].y);
s[1]=(st[i].x-st[k].x)*(st[i].x-st[k].x)+(st[i].y-st[k].y)*(st[i].y-st[k].y);
s[2]=(st[k].x-st[j].x)*(st[k].x-st[j].x)+(st[k].y-st[j].y)*(st[k].y-st[j].y);
// FK(s[0]);
// FK(s[1]);
// FK(s[2]);
sort(s,s+3,cmp);
if(s[0]<s[1]+s[2])return 1;
return 0;
}
int main() {
int T;
int n;
scanf("%d",&T);
bigfor(T) {
scanf("%d",&n);
for(int i=0; i<n; i++) {
scanf("%I64d%I64d",&st[i].x,&st[i].y);
}
LL ans=0;
for(int i=0; i<n; i++) {
for(int j=i+1; j<n; j++) {
for(int k=j+1; k<n; k++) {
if(check(i,j,k)) ans++;
}
}
}
printf("%I64d\n",ans);
}
return 0;
}
ACM: FZU 2110 Star - 数学几何 - 水题
标签:
原文地址:http://www.cnblogs.com/HDMaxfun/p/5789480.html