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