Codeforces Round #432 Div. 2 C. Five Dimensional Points(数学)
来源:互联网 发布:淘宝运营月计划书 编辑:程序博客网 时间:2024/05/29 19:44
C. Five Dimensional Points
time limit per test2 seconds
memory limit per test256 megabytes
inputstandard input
outputstandard 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
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:
题意是:求在5维空间中给出的n个点中有多少个“好点”。
其中好点的定义为:一个点与其他点所组成的向量的夹角大于等于90度。
否则为坏点。
思路:数学很重要,在二维空间中相互垂直的有两个向量,在三维空间中则有三个向量相互垂直。所以在五维空间中,则有五个向量相互垂直。利用则在该空间中若存在相互两两垂直的向量,最多有11个点(五个向量相交的点+五个向量所组成的点=1+2*5),否则肯定不存在好点。若小于三个点,则一定为好点。
#include<stdio.h>#include<iostream>#include<cmath>#include<algorithm>#include<cctype>#include<string.h>#include<queue>#include<stdlib.h>using namespace std;int m[1050][10];bool mark[1050];//mark用来标记那个点为好点,好点为true,坏点为false。int main(){ int n; scanf("%d",&n); for(int i=1;i<=n;i++) { for(int j=1;j<=5;j++) { scanf("%d",&m[i][j]); } } if(n<3)//小于3的情况 { printf("%d\n",n); for(int i=1;i<=n;i++) { printf("%d\n",i); } } else if(n>11)//大于11的情况 { printf("0\n"); } else { int x,y,xy,sum=0; memset(mark,0,sizeof(mark));//开始把所以点都初始化为坏点 for(int i=1;i<=n;i++)//从第一个点开始枚举 { int flag=0;//用来看是否为坏点的标记 for(int j=1;j<=n&&flag==0;j++)//j,k中枚举与i点所组成向量 { if(i==j)continue; for(int k=1;k<=n&&flag==0;k++) { if(i==k||j==k)continue; x=0,y=0,xy=0; for(int z=1;z<=5;z++) { x+=(m[j][z]-m[i][z])*(m[j][z]-m[i][z]);//向量x的模的平方 y+=(m[k][z]-m[i][z])*(m[k][z]-m[i][z]);//向量y的模的平方 xy+=(m[j][z]-m[i][z])*(m[k][z]-m[i][z]);//向量xy的点积 } double s=sqrt(x)*sqrt(y);//向量x与向量y模的乘积 if(acos(xy/s)>=0&&acos(xy/s)<3.1415926/2.0)//小于90度判定的条件 { flag=1;//若为坏点则直接跳出 break; } } if(flag) break; } if(!flag) { mark[i]=1; sum++; } } printf("%d\n",sum); for(int i=1;i<=n;i++) { if(mark[i]) printf("%d\n",i); } } return 0;}
- Codeforces Round #432 Div. 2 C. Five Dimensional Points(数学)
- Codeforces Round #432 (Div. 2) C Five Dimensional Points
- Codeforces Round #432 C. Five Dimensional Points
- Codeforces Round #432 (Div. 2, based on IndiaHacks Final Round 2017)C. Five Dimensional Points
- Codeforces Round #432 (Div. 2) C 850A Five Dimensional Points(思维)
- codeforces 851 C (Div#432) Five Dimensional Points
- Codeforces Round #432 (Div. 1) A.Five Dimensional Points
- Codeforces 851 C Five Dimensional Points(数学概念优化)
- codeforces 851C C. Five Dimensional Points
- Five Dimensional Points CodeForces
- codeforces 851 #432 div2 C Five Dimensional Points
- Codeforces Round #191 (Div. 2) C. Magic Five(数学,逆元取膜模板)
- codeforces 851C Five Dimensional Points 鸽巢定理
- Codeforces 851C . Five Dimensional Points 计算几何,结论
- Codeforces 850 A. Five Dimensional Points(暴力/抽屉定理)
- Codeforces Round #191 (Div. 2) C magic five
- Codeforces Round #191 (Div. 2) C. Magic Five
- Codeforces Round #191 (Div. 2) C. Magic Five
- 注释转换
- hdu 1789 Doing Homework again
- 通过battery-historian分析wakelock对CPU和电池续航能力的影响
- hdu 6178
- 写一篇文章试试,看看审核要多久?
- Codeforces Round #432 Div. 2 C. Five Dimensional Points(数学)
- Rad Studio 10.2.1,Delphi 10.2.1[DVDISO]
- 神经网络注意事项
- 快速搭建简单的springMvc框架的动态web工程
- 最长回文子串
- Java 8
- java多线程 例子
- SSM的医药管理系统(电商系统)
- JavaMail邮件开发(三)