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 2039 & 洛谷 P1791 人员雇佣 —— 二元关系最小割
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=2039 https://www.luogu.org/problemnew/show/P1791 ...
- Android HttpGet和HttpPost设置超时
HttpPost: private Runnable runnable = new Runnable() { @Override public void run() { String url = Ba ...
- android获取时间差的方法
本文实例讲述了android获取时间差的方法.分享给大家供大家参考.具体分析如下: 有些时候我们需要获取当前时间和某个时间之间的时间差,这时如何获取呢? 1. 引用如下命名空间: import jav ...
- ng2 中的全屏与退出全屏
1.进入全屏 launchFullscreen(element) { if(element.requestFullscreen) { element.requestFullscreen(); } el ...
- python并发编程之多线程2死锁与递归锁,信号量等
一.死锁现象与递归锁 进程也是有死锁的 所谓死锁: 是指两个或两个以上的进程或线程在执行过程中,因争夺资源而造成的一种互相等待的现象,若无外力作用, 这些永远在互相等待的进程称为死锁进程 如下就是死锁 ...
- fabric差异化部署mysql和lnmp
1.代码如下: vim lnmp.py ------------------------------------------> #!/usr/bin/env python from fabric ...
- Shape和 layer-list
shape 基本使用 <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android= ...
- CountDownLatch分析
1 什么是CountDownLatch呢? 先看看官网的定义 :一种同步帮助,允许一个或多个线程等待,直到在其他线程中执行的一组操作完成. 现在由我来解释什么是CountDownLatch吧:比如说我 ...
- Postman(调试工具)
Postman Postman用法简介-Http请求模拟工具 时间 2015-09-26 23:52:00 博客园-原创精华区 原文 http://www.cnblogs.com/codingbl ...
- 【总结整理】javascript进阶学习(慕课网)
数组 数组是一个值的集合,每个值都有一个索引号,从0开始,每个索引都有一个相应的值,根据需要添加更多数值. 二维数组 二维数组 一维数组,我们看成一组盒子,每个盒子只能放一个内容. 一维数组的表示: ...