HDU 4173

题意:已知n(n<=200)位參赛选手的住所坐标。现要邀请尽可能多的选手来參加一个party,而每一个选手对于离住所超过2.5Km的party一律不去,求最多能够有多少个选手去參加party。

思路:

最好还是先考虑party可能的位置,要尽可能多的邀请到选手參加,则仅仅需考虑party所在位置在某两位住所连线的中点上或某选手住所所在位置,由于这是最大參加party选手数非常有可能在的位置。

若其它位置能得到最大參加选手数。那么中点或选手住所也一定可得到。

//反证法可得。试着画画就ok~

那么,仅仅要我们枚举全部中点与选手住所的位置。所能得到的可參加party选手数,取其最大值即是答案。

AC code:

/*
* @author Novicer
* language : C++/C
*/
#include<iostream>
#include<sstream>
#include<fstream>
#include<vector>
#include<list>
#include<deque>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cctype>
#include<cmath>
#include<ctime>
#include<iomanip>
using namespace std;
const double eps(1e-8);
typedef long long lint; const int maxn = 200 +5;
pair<double,double>con[maxn]; int main(){
// freopen("input.txt","r",stdin);
int n;
while(cin >> n){
for(int i = 1 ; i <= n ; i++) scanf("%lf%lf",&con[i].first,&con[i].second);
int ans = 0;
for(int i = 1 ; i <= n ; i++){
// cout << con[i].first << " " << con[i].second << endl;
for(int j = 1 ; j <= n ; j++){
pair<double,double> t;
t.first = (con[i].first + con[j].first) / 2.0;
t.second = (con[i].second + con[j].second) / 2.0;
// cout << t.first << " " << t.second << endl;
int cnt = 0;
for(int k = 1 ; k <= n ; k++){
double dis = pow(t.first - con[k].first,2) + pow(t.second - con[k].second,2);
// cout << dis << endl;
if(dis <= 6.25 + eps) cnt++;
}
ans = max(ans , cnt);
}
}
cout << ans << endl;
}
return 0;
}

HDU 4173 Party Location(计算几何,枚举)的更多相关文章

  1. HDU 5130 Signal Interference(计算几何 + 模板)

    HDU 5130 Signal Interference(计算几何 + 模板) 题目链接http://acm.hdu.edu.cn/showproblem.php?pid=5130 Descripti ...

  2. HDU - 5128The E-pang Palace+暴力枚举,计算几何

    第一次写计算几何,ac,感动. 不过感觉自己的代码还可以美化一下. 传送门:http://acm.hdu.edu.cn/showproblem.php?pid=5128 题意: 在一个坐标系中,有n个 ...

  3. hdu - 5128 The E-pang Palace(枚举+计算几何)

    http://acm.hdu.edu.cn/showproblem.php?pid=5128 给出n个点,求n个点组成两个矩形的最大面积. 矩形必须平行x轴,并且不能相交,但是小矩形在大矩形内部是可以 ...

  4. 2017 Multi-University Training Contest - Team 9 1003&&HDU 6163 CSGO【计算几何】

    CSGO Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Subm ...

  5. HDU 4063 Aircraft(计算几何)(The 36th ACM/ICPC Asia Regional Fuzhou Site —— Online Contest)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4063 Description You are playing a flying game. In th ...

  6. HDU 4606 Occupy Cities (计算几何+最短路+最小路径覆盖)

    转载请注明出处,谢谢http://blog.csdn.net/ACM_cxlove?viewmode=contents    by---cxlove 题目:给出n个城市需要去占领,有m条线段是障碍物, ...

  7. HDU 5752 Sqrt Bo【枚举,大水题】

    Sqrt Bo Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total S ...

  8. HDU 5839 Special Tetrahedron 计算几何

    Special Tetrahedron 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5839 Description Given n points ...

  9. HDU 4763 Theme Section(KMP+枚举公共前后缀)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4763 题目大意: 给你一个字符串s,存在一个子串E同时出现在前缀.中间.后缀,即EAEBE这种模式,A ...

随机推荐

  1. Swift学习笔记(5):集合类型

    目录: 数组:Array 集合:Set 字典:Dictionary Swift提供Array(有序集合数据).Set(无序无重复集合)和Dictionary(无序键值对集合)三种基本集合类型来存储明确 ...

  2. Android RecyclerView 水平滚动+自动循环轮播

    主要处理的地方: 1.RecyclerView中Adapter的item个人可以无限轮询. 2.RecyclerView自动滑动 3.手指按下时滑动停止,手指抬起后继续自动滑动 public clas ...

  3. caffe(6) Blob,Layer,Net 以及对应配置文件的编写

    深度网络(net)是一个组合模型,它由许多相互连接的层(layers)组合而成.Caffe就是组建深度网络的这样一种工具,它按照一定的策略,一层一层的搭建出自己的模型.它将所有的信息数据定义为blob ...

  4. k近邻法(k-nearest neighbor, k-NN)

    一种基本分类与回归方法 工作原理是:1.训练样本集+对应标签 2.输入没有标签的新数据,将新的数据的每个特征与样本集中数据对应的特征进行比较,然后算法提取样本最相似数据(最近邻)的分类标签. 3.一般 ...

  5. [NOI2012]随机数生成器 矩阵乘法

    Code: #include<cstdio> #include<algorithm> #include<iostream> #include<cstring& ...

  6. bzoj 2456: mode 思维题 好题

    题目描述: 给你一个 $n$ 个数的数列,其中某个数出现了超过 n div 2 次即众数,请你找出那个数.空间大小:1mb 题解:显然,我们是不能开任何数组的,此题专卡空间.然而我们要求的东西也十分简 ...

  7. perl异常处理

    程序脚本在运行过程中,总会碰到这样那样的问题,我们会预知一些问题并为其准备好处理代码,而有一些不能预知.好的程序要能尽可能多的处理可能出现的异常问题,本文就总结了一些方法来解决这些异常,当然perl在 ...

  8. QQ音乐

    import re import requestsimport json class Search: def __init__(self, song): ''' self.vkey_url ---&g ...

  9. Mybatis传多个参数(推荐)

    Dao层的函数方法 int deleteMsgById(@Param("name") String name,@Param("id") String id); ...

  10. BZOJ 1112 线段树

    思路: 权值线段树 (找中位数用的) 记录下出现的次数和sum 一定要注意 有可能中位数的值有许多数 这怎么办呢 (离散化以后不去重就行了嘛--.) (为什么他们想得那么麻烦) //By Sirius ...