FZU 2110 Star

题意:求有n个点能组成几个锐角三角形,很容易想到:a^2+b^2 > c^2 (c应该是最大的),考虑了精度问题
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int MAXN = 2005;
#define eps 1e-9

struct node{
    double x,y;
};

int check(node a,node b,node c){
    double ans[3];
    ans[0] = (a.x-b.x)*(a.x-b.x) + (a.y-b.y)*(a.y-b.y);
    ans[1] = (a.x-c.x)*(a.x-c.x) + (a.y-c.y)*(a.y-c.y);
    ans[2] = (b.x-c.x)*(b.x-c.x) + (b.y-c.y)*(b.y-c.y);
    sort(ans,ans+3);
    if (ans[2] < ans[0]+ans[1]+eps)
        return 1;
    else return 0;
}

int main(){
    int t;
    scanf("%d",&t);
    while (t--){
        int n;
        node map[MAXN];
        scanf("%d",&n);
        for (int i = 0; i < n; i++)
            scanf("%lf%lf",&map[i].x,&map[i].y);
        int cnt = 0;
        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 (check(map[i],map[j],map[k]))
                        cnt++;
        printf("%d\n",cnt);
    }
    return 0;
}



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值