• 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;
    }
    


  • 相关阅读:
    html之长文本框置顶
    Red Hat Enterprise Linux Server 6.5安装GCC 4.9.2
    精通正则表达式
    解决UNION ALL合并两个结果集后排序的问题
    ELK搭建日志管理系统记录
    Spring Boot使用@ConfigurationProperties 读取自定义的properties的方法
    maven配置profile,按指定环境打包
    java自定义标签,tld文件,获取数据字典的值
    JAVA实现RSA签名、验签
    jquery.validate.js中的remote用法
  • 原文地址:https://www.cnblogs.com/da-mei/p/9053308.html
Copyright © 2020-2023  润新知