http://codeforces.com/gym/101055/problem/A

题目:给定一些三维空间的点,要你找一个平面,能覆盖尽量多的点,只要求输出点数即可。n<=50

因为数据量小,我们考虑暴力。

首先,三个不在同一条直线的点,确定一个平面,然后枚举其他的点。判断一下,这样的复杂度是n^4。可以接受

特判。所有点都在同一条直线。直接输出n、

后面的,枚举三个点后,能算出这个平面的法向量,然后枚举其他点,与法向量的数量积是0的,就可以ans++

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
#define inf (0x3f3f3f3f)
typedef long long int LL; #include <iostream>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
const int maxn = +;
struct coor
{
int x,y,z;//坐标,也可以表示成向量,向量也是一个坐标表示嘛
coor(){}
coor(int xx,int yy,int zz):x(xx),y(yy),z(zz){}
bool operator &(coor a) const //判断两个向量是否共线,共线返回true
{
//思路:判断叉积,是否各项系数都是0
return (y*a.z - z*a.y)== && (z*a.x - x*a.z)== && (x*a.y - y*a.x)==;
}
coor operator ^(coor a) const //得到两个向量的叉积(就是向量积),返回的是一个向量(坐标)
{
return coor(y*a.z - z*a.y,z*a.x - x*a.z,x*a.y - y*a.x);
}
coor operator -(coor a) const //如果是c-d的话,得到向量dc,
{
return coor(x-a.x,y-a.y,z-a.z);
}
int operator *(coor a) const //得到两个向量的 数量积,返回整数即可
{
return x*a.x+y*a.y+z*a.z;
}
}a[maxn];
bool all_in_Aline(int n)
{
//思路,暴力枚举,每三个点,看看是不是所有叉积都是0
for (int i=;i<=n;++i) //这个作为起点吧
for (int j=i+;j<=n;++j)
for (int k=j+;k<=n;++k)
{
coor t1 = a[k]-a[i];
coor t2 = a[j]-a[i];
if (t1&t2) continue;
return false;
}
return true;
}
bool checkThree (coor a,coor b,coor c)
{
return (b-a)&(c-a);
}
void work ()
{
int n;
cin>>n;
for (int i=;i<=n;++i) cin>>a[i].x>>a[i].y>>a[i].z;
if (all_in_Aline(n)) //如果都在同一直线,直接判断即可
{
cout<<n<<endl;
return ;
}
int ans=;
for (int i=;i<=n;++i)
for (int j=i+;j<=n;++j)
for (int k=j+;k<=n;++k)
{
if (checkThree(a[i],a[j],a[k])) continue;
int t=;
coor t1 = (a[k]-a[i])^(a[j]-a[i]); //垂直的向量
for (int h=;h<=n;++h)
{
if (h==i||h==j||h==k) continue;
if ((a[h]-a[i])*t1 == ) t++;
}
ans = max(ans,t);
}
cout<<ans<<endl;
return ;
} int main()
{
#ifdef local
freopen("data.txt","r",stdin);
#endif
work();
return ;
}

Gym 101055A 计算几何,暴力的更多相关文章

  1. HDU 6697 Closest Pair of Segments (计算几何 暴力)

    2019 杭电多校 10 1007 题目链接:HDU 6697 比赛链接:2019 Multi-University Training Contest 10 Problem Description T ...

  2. Codeforces Gym 100531D Digits 暴力

    Problem D. Digits 题目连接: http://codeforces.com/gym/100531/attachments Description Little Petya likes ...

  3. Codeforces Gym 100418K Cards 暴力打表

    CardsTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/view.action? ...

  4. BZOJ 1199: [HNOI2005]汤姆的游戏 计算几何暴力

    1199: [HNOI2005]汤姆的游戏 Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://www.lydsy.com/JudgeOnline/p ...

  5. Rasheda And The Zeriba Gym - 100283A  计算几何

    http://codeforces.com/gym/100283/problem/A 考虑到多边形是不稳定的,是可以变来变去的. 那么总是可以把每个点放到圆上. 所以只需要判断圆心角是不是小于等于36 ...

  6. Gym 100531D Digits (暴力)

    题意:给定一个数字,问你找 n 个数,使得这 n 个数各位数字之和都相等,并且和最小. 析:暴力,去枚举和是 1 2 3...,然后去选择最小的. 代码如下: #pragma comment(link ...

  7. ACM/ICPC 之 三维计算几何+暴力枚举+判重(HDU5839)

    CCPC网赛第八题,求立体几何数量,题解见注释 //立体几何-求满足要求的四面体个数 //要求1:至少4条边相等 //要求2:四条边相等时,另两条边一定不相邻(即对边) //题解:以当前边为不相邻的其 ...

  8. Five Dimensional Points CodeForces - 851C (计算几何+暴力)

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

  9. L - Ray in the tube Gym - 101911L (暴力)

    ---恢复内容开始--- You are given a tube which is reflective inside represented as two non-coinciding, but ...

随机推荐

  1. Maven运行JUnit测试(http://www.360doc.com/content/13/0927/15/7304817_317455642.shtml)

    Maven单元测试 分类: maven 2012-05-09 15:17 1986人阅读 评论(1) 收藏 举报 maven测试junit单元测试javarandom   目录(?)[-] maven ...

  2. VMware里Ubuntu-16.04-desktop的VMware Tools安装图文详解

    不多说,直接上干货! 总的来说,根据分为三个步骤. 步骤一: 点击 :虚拟机—–>安装VM tools 然后发现桌面会跳出如下问题: 客户机操作系统已将 CD-ROM 门锁定,并且可能正在使用 ...

  3. Fast Walsh–Hadamard transform

    考虑变换 $$\hat{A_x} = \sum_{i\ or\ x = x}{ A_i }$$ 记 $S_{t}(A,x) = \sum_{c(i,t)\ or\ c(x,t)=c(x,t),\ i ...

  4. python变量、类型、运算、输出

    1.变量.类型.运算.输出等 # -*- coding: utf-8 -*- a=2 b=3 c=a+b print u'结果是=%i'%c #加u显示中文 str=unicode(s,"u ...

  5. TCP/IP四层体系结构

    1.数据链路层  2.网络层  3.传输层  4.应用层 , 其中IP是在第二层网络层中,TCP是在第3层传输层中, Internet体系结构最重要的是TCP/IP协议,是实现互联网络连接性和互操作性 ...

  6. 项目:条件查询 通过StringBulider和ArrayList(参数有序) 手动拼接sql

    条件查询的sql拼接 参数拼接 public List<Product> findAll(Product product) throws SQLException { //1.1 拼凑sq ...

  7. 文件格式——fastq格式

    fastQ格式 FASTQ是一种存储了生物序列(通常是核酸序列)以及相应的质量评价的文本格式. 他们都是以ASCII编码的.现在几乎是高通量测序的标准格式.NCBI Short Read Archiv ...

  8. p2341&bzoj1051 受欢迎的牛

    传送门(洛谷) 传送门(bzoj) 题目 每一头牛的愿望就是变成一头最受欢迎的牛.现在有N头牛,给你M对整数(A,B),表示牛A认为牛B受欢迎. 这 种关系是具有传递性的,如果A认为B受欢迎,B认为C ...

  9. Umbraco back office 中templates显示不出来问题解决 (一片空白)

    在公司一个项目中,遇到一个问题,登录Umbraco back office,该项目的settings => Templates 已经有该项目的10几个view (templates), 但是,点 ...

  10. nginx manager

    ====================================================@echo offrem 当前bat的作用 echo ==================beg ...