• CodeForces


     Five Dimensional Points

    You are given set of n points in 5-dimensional space. The points are labeled from 1 to n. No two points coincide.


    We will call point a bad if there are different points b and c, not equal to a, from the given set such that angle between vectors  and  is acute (i.e. strictly less than ). Otherwise, the point is called good.


    The angle between vectors  and  in 5-dimensional space is defined as , where  is the scalar product and  is length of .


    Given the list of points, print the indices of the good points in ascending order.


    Input
    The first line of input contains a single integer n (1 ≤ n ≤ 103) — the number of points.


    The next n lines of input contain five integers ai, bi, ci, di, ei (|ai|, |bi|, |ci|, |di|, |ei| ≤ 103)  — the coordinates of the i-th point. All points are distinct.


    Output
    First, print a single integer k — the number of good points.


    Then, print k integers, each on their own line — the indices of the good points in ascending order.


    Example
    Input
    6
    0 0 0 0 0
    1 0 0 0 0
    0 1 0 0 0
    0 0 1 0 0
    0 0 0 1 0
    0 0 0 0 1
    Output
    1
    1
    Input
    3
    0 0 1 2 0
    0 0 9 2 0
    0 0 5 9 0
    Output
    0
    Note
    In the first sample, the first point forms exactly a  angle with all other pairs of points, so it is good.


    In the second sample, along the cd plane, we can see the points look as follows:





    We can see that all angles here are acute, so no points are good.

    题意:任意两边的夹角不能小于九十度。

    思路:当点大于11个的时候就会有小于九十度的角。

    #include<stdio.h>
    #include<iostream>
    #include<math.h>
    #include<string.h>
    #include<algorithm>
    #define pi 3.1415926
    using namespace std;
    int a[1005][10];
    int b[1005];
    int x[10000];
    int y[10000];
    double  w(int e,int r,int t)
    {
        int xy=0;
        int X=0,Y=0;
        for(int i=0; i<5; i++)
        {
            x[i]=a[e][i]-a[t][i];
            y[i]=a[r][i]-a[t][i];
            xy+=x[i]*y[i];
            X+=x[i]*x[i];
            Y+=y[i]*y[i];
        }
        X=sqrt(X*1.0);
        Y=sqrt(Y*1.0);
        double yx=(xy*1.0)/(X*Y*1.0);
        //cout<<yx<<endl;
        if(yx>=-1&&yx<=1)
        {
            yx=acos(yx);
            return (yx/pi)*180;
        }
        else
            return 0;
    }
    int main()
    {
        int n;
        cin>>n;
        for(int i=0; i<n; i++)
        {
            for(int j=0; j<5; j++)
            {
                cin>>a[i][j];
            }
        }
        if(n>11)
        {
            cout<<0<<endl;
            return 0;
        }
        int s=0;
        for(int i=0; i<n; i++)
        {
            int flag=0;
            for(int j=0; j<n; j++)
            {
                if(j!=i)
                {
                    for(int k=j+1; k<n; k++)
                    {
                        if(i!=j&&j!=k&&i!=k)
                        {
                            //cout<<i<<j<<k<<endl;
                            double p=w(k,j,i);
                            //cout<<p<<endl;
                            if(p<90)
                                flag=1;
    
                        }
                    }
                }
            }
            if(flag==0)
            {
                b[s++]=i+1;
            }
        }
        cout<<s<<endl;
        for(int i=0; i<s; i++)
            cout<<b[i]<<" ";
        cout<<endl;
    }
    


  • 相关阅读:
    java爬虫(八)使用node.js获取network中api接口内信息并用java的jsoup重写该方法
    java爬虫(七)使用httpclient模拟浏览器GET,POST
    Java selenium对cookies的操作
    java爬虫(六)分析AJAX接口获取网页动态内容
    java爬虫(五)利用selenium 模拟点击获取动态页面的内容
    java爬虫(四)利用Jsoup获取需要登陆的网站中的内容(无验证码的登录)
    java爬虫(三)利用HttpClient和Jsoup模拟网页登陆(无验证码)
    Java远程服务器调优
    20 vue-router的使用
    19 关于Vue中main.js,App.vue,index.html之间关系进行总结
  • 原文地址:https://www.cnblogs.com/da-mei/p/9053308.html
Copyright © 2020-2023  润新知