Gym 101055A 计算几何,暴力
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 计算几何,暴力的更多相关文章
- HDU 6697 Closest Pair of Segments (计算几何 暴力)
2019 杭电多校 10 1007 题目链接:HDU 6697 比赛链接:2019 Multi-University Training Contest 10 Problem Description T ...
- Codeforces Gym 100531D Digits 暴力
Problem D. Digits 题目连接: http://codeforces.com/gym/100531/attachments Description Little Petya likes ...
- Codeforces Gym 100418K Cards 暴力打表
CardsTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/view.action? ...
- BZOJ 1199: [HNOI2005]汤姆的游戏 计算几何暴力
1199: [HNOI2005]汤姆的游戏 Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://www.lydsy.com/JudgeOnline/p ...
- Rasheda And The Zeriba Gym - 100283A 计算几何
http://codeforces.com/gym/100283/problem/A 考虑到多边形是不稳定的,是可以变来变去的. 那么总是可以把每个点放到圆上. 所以只需要判断圆心角是不是小于等于36 ...
- Gym 100531D Digits (暴力)
题意:给定一个数字,问你找 n 个数,使得这 n 个数各位数字之和都相等,并且和最小. 析:暴力,去枚举和是 1 2 3...,然后去选择最小的. 代码如下: #pragma comment(link ...
- ACM/ICPC 之 三维计算几何+暴力枚举+判重(HDU5839)
CCPC网赛第八题,求立体几何数量,题解见注释 //立体几何-求满足要求的四面体个数 //要求1:至少4条边相等 //要求2:四条边相等时,另两条边一定不相邻(即对边) //题解:以当前边为不相邻的其 ...
- Five Dimensional Points CodeForces - 851C (计算几何+暴力)
C. Five Dimensional Points time limit per test 2 seconds memory limit per test 256 megabytes input ...
- L - Ray in the tube Gym - 101911L (暴力)
---恢复内容开始--- You are given a tube which is reflective inside represented as two non-coinciding, but ...
随机推荐
- RPG游戏地牢设计的29个要点
转自:http://www.gameres.com/491660.html Troy 是一名 RPG 开发者,以整理了一些自己开发地下城 RPG 的经验,开发者不妨参考一下: 1.地下城应该有个地方无 ...
- 新版 Spring下载方法
1.百度 Spring 打开官方网站 http://spring.io/ 2.======================================= 3.================= ...
- Linux TCP通信例子
TCP通信的C/S模型 ///server.c #include <sys/types.h> #include <sys/socket.h> #include <stdi ...
- JavaScript中的BOM知识框架
浏览器对象模型(BOM)以window对象为依托,表示浏览器窗口及可见区域.同时,window对象和还是全局对象,因此所有求安局变量和函数都是它的属性,所有原生框架及其他函数都在它命名之下.BOM中对 ...
- 关于startservice的几个启动返回值的意义
START_NOT_STICKY 如果服务进程在它启动后(从onStartCommand()返回后)被kill掉, 并且没有新启动的intent传给他, 那么将服务移出启动状态并且不重新生成, 直到再 ...
- 树莓派 Learning 002 装机后的必要操作 --- 04 添加软件源 之 添加公钥 --- 解决“由于没有公钥,无法验证下列签名”问题
树莓派 装机后的必要操作 - 添加软件源 解决 添加公钥 时会遇到的问题 当你添加完Debian的软件源后,在终端中执行sudo apt-get update时,会出现下面的错误:(这里我添加了3个软 ...
- eclipse 远程操作HIVE
首先启动HiveServer hive --service hiveserver 10000 & 创建工程 引入包: 代码(简单的查询): package com.hive.jdbc; imp ...
- 18. CTF综合靶机渗透(十一)
靶机描述: SkyDog Con CTF 2016 - Catch Me If You Can 难度:初学者/中级 说明:CTF是虚拟机,在虚拟箱中工作效果最好.下载OVA文件打开虚拟框,然后选择文件 ...
- product of大数据平台搭建------CM 和CDH安装
一.安装说明 CM是由cloudera公司提供的大数据组件自动部署和监控管理工具,相应的和CDH是cloudera公司在开源的hadoop社区版的基础上做了商业化的封装的大数据平台. 采用离线安装模式 ...
- IOS 完成来电归属地
首先是一个库:(有时间在上传) 然后设置一个工具类 .h @interface HMFoundLocation : NSObject AS_SINGLETON(HMFoundLocation) @pr ...