Codeforces 850A - Five Dimensional Points(暴力)

原题链接:http://codeforces.com/problemset/problem/850/A

题意:有n个五维空间内的点,如果其中三个点A,B,C,向量AB,AC的夹角不大于90°,则点A是“bad”的否则是“good”。题目让我们输出good的点。

思路:从2,3维空间超过5,7个点时不存在“good”的点,可以简单推知五维空间内,超过11个点时不存在“good”的点,那么点数小于11时暴力,大于11时输出0.

其实由于数据量小,直接暴力也是可行的。

AC代码:

 1 #include<iostream>
 2 #include<cstring>
 3 #include<cstdio>
 4 #include<vector>
 5 using namespace std;
 6 const int MAXN=1005;
 7 struct Node{
 8     int a,b,c,d,e;
 9 }node[MAXN];
10 bool pend(Node A, Node B, Node C)
11 {
12     Node AB,AC;
13     AB.a=B.a-A.a;
14     AB.b=B.b-A.b;
15     AB.c=B.c-A.c;
16     AB.d=B.d-A.d;
17     AB.e=B.e-A.e;
18     AC.a=C.a-A.a;
19     AC.b=C.b-A.b;
20     AC.c=C.c-A.c;
21     AC.d=C.d-A.d;
22     AC.e=C.e-A.e;
23     if(AB.a*AC.a+AB.b*AC.b+AB.c*AC.c+AB.d*AC.d+AB.e*AC.e<=0) return 0;
24     return 1;
25 }
26 int main()
27 {
28     int n;
29     while(cin>>n)
30     {
31
32         vector<int> res;
33         for(int i=0;i<n;i++){
34             scanf("%d %d %d %d %d", &node[i].a, &node[i].b, &node[i].c, &node[i].d ,&node[i].e);
35         }
36         if(n==1){
37             printf("%d\n%d\n", 1, 1);
38             continue;
39         }
40         else if(n==2){
41             printf("%d\n%d\n%d\n", 2, 1, 2);
42             continue;
43         }
44         else if(n>11){
45             printf("%d\n", 0);
46             continue;
47         }
48         bool flag;
49         for(int i=0;i<n;i++){
50             flag=0;
51             for(int j=0;j<n;j++){
52                 for(int k=j+1;k<n;k++){
53                     if(pend(node[i], node[j], node[k])){
54                         flag=1;
55                         j=n+1;
56                         break;
57                     }
58                 }
59             }
60             if(!flag) res.push_back(i);
61         }
62         int l=res.size();
63         printf("%d\n", l);
64         for(int i=0;i<l;i++)
65             printf("%d\n", res[i]+1);
66     }
67     return 0;
68 }
时间: 2024-08-01 10:42:34

Codeforces 850A - Five Dimensional Points(暴力)的相关文章

Codeforces 443A Borya and Hanabi(暴力)

题目链接:Codeforces 443A Borya and Hanabi 题目大意:有若干个牌,每张牌有花色和数字两个值,现在问说至少询问多少次才能区分出所有的牌,每次询问可以确定一种花色牌的位置,或者是一种数字牌的位置. 解题思路:暴力枚举需要问的花色和数字,210,然后枚举两两判断是否可以被区分. #include <cstdio> #include <cstring> #include <algorithm> using namespace std; const

Codeforces Gym 100203G Good elements 暴力乱搞

原题链接:http://codeforces.com/gym/100203/attachments/download/1702/statements.pdf 题解 考虑暴力的复杂度是O(n^3),所以我们需要记录所有的ai+aj,如果当前考虑到了ak,那么就去前面寻找ai,使得ak-ai是我们记录过的和.整个算法的复杂度O(n^2). 代码 #include<iostream> #include<cstring> #include<cstdio> #include<

Codeforces Gym 100637G G. #TheDress 暴力

G. #TheDress Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100637/problem/G Description After landing on planet i1c5l people noticed that blue and black clothes are quite popular among the locals. Each aboriginal has at least

Codeforces gym 100685 A. Ariel 暴力

A. ArielTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100685/problem/A Description King Triton really likes watching sport competitions on TV. But much more Triton likes watching live competitions. So Triton decides to set up

Codeforces 839D Winter is here - 暴力 - 容斥原理

Winter is here at the North and the White Walkers are close. John Snow has an army consisting of n soldiers. While the rest of the world is fighting for the Iron Throne, he is going to get ready for the attack of the White Walkers. He has created a m

CodeForces 200C Football Championship(暴力枚举)

C. Football Championship time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Any resemblance to any real championship and sport is accidental. The Berland National team takes part in the local

Codeforces 460E Roland and Rose(暴力)

题目链接:Codeforces 460E Roland and Rose 题目大意:在以原点为圆心,半径为R的局域内选择N个整数点,使得N个点中两两距离的平方和最大. 解题思路:R最大为30,那么其实距离圆心距离最大的整数点不过12个最多,直接暴力枚举. #include <cstdio> #include <cstring> #include <vector> #include <algorithm> using namespace std; struct

CodeForces 702B Powers of Two (暴力,优化)

题意:给定 n 个数,问你从有多少下标 i < j,并且 ai + aj 是2的倍数. 析:方法一: 从输入开始暴力,因为 i < j 和 i > j 是一样,所以可以从前面就开始查找,然后计数,用个map就搞定,不过时间有点长,接近两秒. 方法二: 先排序,然后暴力,暴力的原则是找前面的,也是用map查找,时间62ms. 代码如下: #include <cstdio> #include <string> #include <cstdlib> #inc

[CodeForces-1036E] Covered Points 暴力 GCD 求交点

题意: 在二维平面上给出n条不共线的线段,问这些线段总共覆盖到了多少个整数点 解法: 用GCD可求得一条线段覆盖了多少整数点,然后暴力枚举线段,求交点,对于相应的 整数交点,结果-1即可 1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 #include<iostream> 5 #include<cmath> 6 #include<vector> 7 #inc