HDU 4173 Party Location(计算几何,枚举)
题意:已知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(计算几何,枚举)的更多相关文章
- HDU 5130 Signal Interference(计算几何 + 模板)
HDU 5130 Signal Interference(计算几何 + 模板) 题目链接http://acm.hdu.edu.cn/showproblem.php?pid=5130 Descripti ...
- HDU - 5128The E-pang Palace+暴力枚举,计算几何
第一次写计算几何,ac,感动. 不过感觉自己的代码还可以美化一下. 传送门:http://acm.hdu.edu.cn/showproblem.php?pid=5128 题意: 在一个坐标系中,有n个 ...
- hdu - 5128 The E-pang Palace(枚举+计算几何)
http://acm.hdu.edu.cn/showproblem.php?pid=5128 给出n个点,求n个点组成两个矩形的最大面积. 矩形必须平行x轴,并且不能相交,但是小矩形在大矩形内部是可以 ...
- 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 ...
- 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 ...
- HDU 4606 Occupy Cities (计算几何+最短路+最小路径覆盖)
转载请注明出处,谢谢http://blog.csdn.net/ACM_cxlove?viewmode=contents by---cxlove 题目:给出n个城市需要去占领,有m条线段是障碍物, ...
- HDU 5752 Sqrt Bo【枚举,大水题】
Sqrt Bo Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total S ...
- HDU 5839 Special Tetrahedron 计算几何
Special Tetrahedron 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5839 Description Given n points ...
- HDU 4763 Theme Section(KMP+枚举公共前后缀)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4763 题目大意: 给你一个字符串s,存在一个子串E同时出现在前缀.中间.后缀,即EAEBE这种模式,A ...
随机推荐
- ASP.NET Identity 角色管理(Roles)
当我们使用ASP.NET 4.5创建模板项目时,会发现模板只提供了ApplicationUserManager用于用户的登录注册.修改.设置等,而没有提供与用户角色相关的代码,对此就需要我们自己手动的 ...
- Bootstrap modal.js 源码分析
/* ======================================================================== * Bootstrap: modal.js v3 ...
- appium 模拟实现物理按键点击
appium自动化测试中,当确认,搜索,返回等按键通过定位点击不好实现的时候,可以借助物理按键来实现.appium支持以下物理按键模拟: 电话键 KEYCODE_CALL 拨号键 5 KEYCODE_ ...
- celery 学习
1. 列出计划的ETA任务(worker) celery -A proj inspect scheduled 参考文档:http://docs.celeryproject.org/en/latest/ ...
- numpy基础篇-简单入门教程2
import numpy as np Array 数组 print(np.zeros((2, 2))) # [[0. 0.] [0. 0.]] print(np.ones((2, 2))) # [[1 ...
- Win 7中开启Telnet功能
参看以下文章: http://winsystem.ctocio.com.cn/Longhorn/472/8756972.shtml
- 9 hbase源码系列(九)StoreFile存储格式
hbase源码系列(九)StoreFile存储格式 从这一章开始要讲Region Server这块的了,但是在讲Region Server这块之前得讲一下StoreFile,否则后面的不好讲下去 ...
- Spring-statemachine给end状态设置action
Spring-statemachine版本:当前最新的1.2.3.RELEASE版本 builder.configureStates() .withStates() .initial(generate ...
- ADL & 实参相依的查找 & 成员与非成员的查找
也就是会根据实参,所处在的名字空间,来查找对应名字空间里面的函数. 对于<<也是常见的场景,会根据实际要打印出来的下一个操作数,来决定调用哪个命名空间里面的函数. 注意,不同命名空间里面的 ...
- 怎样使用纯CSS3创建一个简单的五角星图形
我们能够使用SVG.Canvas.CSS3或者背景图片来实现五角星图案及其悬停效果. CSS3引入的伪元素和变换特性使得实现五角星图形很easy,而且能够结合渐变实现更为美丽的效果.因此使用图片实现五 ...