Codeforces Round #432 (Div. 2) C Five Dimensional Points

题目链接:点击打开链接

五维空间下的锐角判定(包括0)只需判断向量的数量积是否大于0即可

暴力枚举所有可能性

AC代码如下:

#include <iostream>
#include <cmath>
#include <cstring>

using namespace std;

struct point{
    int x1, x2, x3, x4, x5;
    point operator-(const point& o)
    {
        point t;
        t.x1 = x1-o.x1;
        t.x2 = x2-o.x2;
        t.x3 = x3-o.x3;
        t.x4 = x4-o.x4;
        t.x5 = x5-o.x5;
        return t;
    }

};

point pPoint[1005];
bool re[1005];

bool judge(point a, point b)
{
    double temp = a.x1*b.x1+a.x2*b.x2+a.x3*b.x3+a.x4*b.x4+a.x5*b.x5;
    return  temp>0;
}

bool onLine(point a, point b)
{
    if(a.x1*b.x2!=a.x2*b.x1)    return false;
    if(a.x2*b.x3!=a.x3*b.x2)    return false;
    if(a.x3*b.x4!=a.x3*b.x4)    return false;
    if(a.x4*b.x5!=a.x5*b.x4)    return false;
    return true;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    while(cin>>n)
    {
        fill(re+1,re+1+n,1);
        for(int i=1;i<=n;++i)
        {
            cin>>pPoint[i].x1>>pPoint[i].x2;
            cin>>pPoint[i].x3>>pPoint[i].x4>>pPoint[i].x5;
        }
        int cnt=0;
        for(int i=1;i<=n;++i)
        {
            int flag=0;
            for(int j=1;j<=n;++j)
            {
                if(j==i)    continue;
                for(int k=1;k<=n;++k)
                {
                    if(k==i||k==j)  continue;
                    point a = pPoint[j]-pPoint[i];
                    point b = pPoint[k]-pPoint[i];
                    if(judge(a,b))    { flag=1; break; }
                }
                if(flag)     break;
            }
            if(flag)    {  cnt++; re[i]=0;}
        }
        cout<<n-cnt<<endl;
        for(int i=1;i<=n;++i)
            if(re[i])   cout<<i<<endl;
    }
    return 0;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值