zoukankan      html  css  js  c++  java
  • C. Five Dimensional Points

    C. Five Dimensional Points
    time limit per test
    2 seconds
    memory limit per test
    256 megabytes
    input
    standard input
    output
    standard output

    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.

    Examples
    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.

    题意:

    有n个五维的点,求有多少个“好“点,对于“好”点、“坏”点的定义如下:

    “好”点:设该点为a,在所给点中任意两个不相等且不为a的点b,c,向量ab与向量bc的夹角均不为锐角。

    “坏”点:不是“好”点的点都是“坏”点

    暴力求解;

     

     1 #include <bits/stdc++.h>
     2 #define N 1005
     3 using namespace std;
     4 int cnt=0;
     5 struct Node{
     6   int a,b,c,d,e;
     7 }k[N];
     8 int as[N];
     9 queue<int> s;
    10 int ssr(Node a,Node b,Node c){ return (a.a-b.a)*(c.a-b.a)+(a.b-b.b)*(c.b-b.b)+(a.c-b.c)*(c.c-b.c)+(a.d-b.d)*(c.d-b.d)+(a.e-b.e)*(c.e-b.e);
    11 }
    12 int main(){
    13   int n;
    14   scanf("%d",&n);
    15   cnt=n;
    16   for(int i=1;i<=n;i++){
    17       scanf("%d%d%d%d%d",&k[i].a,&k[i].b,&k[i].c,&k[i].d,&k[i].e);
    18   }
    19   memset(as,0,sizeof(as));
    20   for(int i=1;i<=n;i++){
    21     for(int j=1;j<=n;j++){
    22       for(int t=j+1; t<=n;t++){
    23         if(i!=j&&i!=t&&ssr(k[j],k[i],k[t])>0){
    24           as[i]=1;
    25           cnt--;
    26           goto eg;
    27         }
    28       }
    29     }
    30     eg:;
    31   }
    32   printf("%d
    ",cnt);
    33   for(int i=1;i<=n;i++){
    34     if(as[i]==0)
    35       printf("%d
    ",i);
    36   }
    37   return 0;
    38 }

     

     

     

  • 相关阅读:
    GZDBHelper C#.NET开源的数据库访问组件
    判断页面是否是静态页面
    Web应用程序dll获取当前程序集路径问题
    webAPI 上传文件
    解决.Net Core3.0 修改cshtml代码之后必须重新生成才可以看到效果
    .net core使用LESS
    test
    JS实现线程锁(Promise),NodeJS并发锁处理
    参考护照编码实现算法JS生成带字母有序编码
    centos7防火墙开放端口与关闭防火墙
  • 原文地址:https://www.cnblogs.com/zllwxm123/p/7497415.html
Copyright © 2011-2022 走看看