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. bzoj 2007 海拔 —— 最短路

    题目:https://www.lydsy.com/JudgeOnline/problem.php?id=2007 最后一定是起点周围一片0,终点周围一片1: 所以建出图来跑最短路即可. 代码如下: # ...

  2. poj 2388 Who's in the Middle(快速排序求中位数)

    一.Description FJ is surveying his herd to find the most average cow. He wants to know how much milk ...

  3. HDOJ(1069)最长下降子序列

    每个箱子可有3种叠加方式,所以有3*n个箱子.将箱子按长度由大到小排序,有求箱子按宽度的最长下降子序列的高度之和即可. #include<cstdio> #include<algor ...

  4. JVM体系结构之五:本地方法栈

    对于一个运行中的Java程序而言,它还可能会用到一些跟本地方法相关的数据区.当某个线程调用一个本地方法时,它就进入了一个全新的并且不再受虚拟机限制的世界.本地方法可以通过本地方法接口来访问虚拟机的运行 ...

  5. DTP模型之一:(XA协议之一)XA协议、二阶段2PC、三阶段3PC提交

    XA协议 XA是一个分布式事务协议,由Tuxedo提出.XA中大致分为两部分:事务管理器和本地资源管理器.其中本地资源管理器往往由数据库实现,比如Oracle.DB2这些商业数据库都实现了XA接口,而 ...

  6. 开发框架:AdminLTE

    ylbtech-开发框架:AdminLTE 1.返回顶部   2.返回顶部   3.返回顶部   4.返回顶部 1. 2. 5.返回顶部 1. https://adminlte.io 2.   6.返 ...

  7. Python知识点: os.popen

    用例:f = os.popen("%s %s %s" % ("pkg-config", " ".join(args), mod)) pope ...

  8. J2EE 工作中注意事项

    [转载于http://www.cnblogs.com/hemingwang0902/archive/2012/01/06/2314215.html] 根据当前项目中代码存在的一些问题,编写了一个编码注 ...

  9. 动态Result配置

    步骤一:建立DynaAction,主要代码如下: package com.asm; public class DynaAction extends ActionSupport { private St ...

  10. 掌握HDFS的Java API接口访问

    HDFS设计的主要目的是对海量数据进行存储,也就是说在其上能够存储很大量文件(可以存储TB级的文件).HDFS将这些文件分割之后,存储在不同的DataNode上, HDFS 提供了两种访问接口:She ...