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 ...
随机推荐
- bzoj 2632 [ neerc 2011 ] Gcd guessing game —— 贪心
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=2632 官方题解:http://neerc.ifmo.ru/archive/2011/neer ...
- 【转】 Pro Android学习笔记(四九):ActionBar(2):Action图标区
目录(?)[-] ActionBar的隐藏和现实 ActionBar的action图标区 ActionBar的隐藏和现实 ActionBar bar = getActionBar();bar.hide ...
- canvas线条笔帽及连接
1) 线条笔帽篇: 1 function draw (id) { 2 var canvas = document.getElementById(id); 3 context = canvas.getC ...
- nginx做代理部署WordPress
实验环境:CentOS7 服务器172.16.252.142做Nginx代理服务器: [root@conf.d localhost]#iptables -F [root@conf.d localhos ...
- String/ StringBuilder/ StringBuffer
1. 首先String不属于8种基本数据类型,String是一个对象. 因为对象的默认值是null,所以String的默认值也是null:但它又是一种特殊的对象,有其它对象没有的一些特性. 2. ne ...
- 动态Result配置
步骤一:建立DynaAction,主要代码如下: package com.asm; public class DynaAction extends ActionSupport { private St ...
- [#413c] Fountains
http://codeforces.com/contest/799/problem/C 解题关键:树状数组取最大值,注意先搜索,后加入,此种情况可以取出最大值. 为什么可以取到最大值? 1.当分别用两 ...
- linux 安装输入法
简述 Ubuntu16.04安装完后,和12.04以及14.04都不一样,并没有中文输入功能.于是搜索一些安装中文输入法的方法. 开始安装了ibus pinyin输入法,但是系统重启之后发现有些时候不 ...
- 树莓派 Learning 002 装机后的必要操作 --- 01 解决上网问题
树莓派 装机后的必要操作 - 解决上网问题 我的树莓派型号:Raspberry Pi 2 Model B V1.1 装机系统:NOOBS v1.9.2 树莓派 装机后的必要操作 解决上网问题 解决上网 ...
- Learning Python 010 函数 1
Python 函数 1 调用函数 举个例子 多于Python内部的函数,你可以在Python的交互式终端中使用help()函数来查看函数的使用方法.比如:abs()函数,如果你不知道如何使用它,你可以 ...