HDU 4173

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

思路:

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

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

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

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

AC code:

  1. /*
  2. * @author Novicer
  3. * language : C++/C
  4. */
  5. #include<iostream>
  6. #include<sstream>
  7. #include<fstream>
  8. #include<vector>
  9. #include<list>
  10. #include<deque>
  11. #include<queue>
  12. #include<stack>
  13. #include<map>
  14. #include<set>
  15. #include<bitset>
  16. #include<algorithm>
  17. #include<cstdio>
  18. #include<cstdlib>
  19. #include<cstring>
  20. #include<cctype>
  21. #include<cmath>
  22. #include<ctime>
  23. #include<iomanip>
  24. using namespace std;
  25. const double eps(1e-8);
  26. typedef long long lint;
  27.  
  28. const int maxn = 200 +5;
  29. pair<double,double>con[maxn];
  30.  
  31. int main(){
  32. // freopen("input.txt","r",stdin);
  33. int n;
  34. while(cin >> n){
  35. for(int i = 1 ; i <= n ; i++) scanf("%lf%lf",&con[i].first,&con[i].second);
  36. int ans = 0;
  37. for(int i = 1 ; i <= n ; i++){
  38. // cout << con[i].first << " " << con[i].second << endl;
  39. for(int j = 1 ; j <= n ; j++){
  40. pair<double,double> t;
  41. t.first = (con[i].first + con[j].first) / 2.0;
  42. t.second = (con[i].second + con[j].second) / 2.0;
  43. // cout << t.first << " " << t.second << endl;
  44. int cnt = 0;
  45. for(int k = 1 ; k <= n ; k++){
  46. double dis = pow(t.first - con[k].first,2) + pow(t.second - con[k].second,2);
  47. // cout << dis << endl;
  48. if(dis <= 6.25 + eps) cnt++;
  49. }
  50. ans = max(ans , cnt);
  51. }
  52. }
  53. cout << ans << endl;
  54. }
  55. return 0;
  56. }

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. What are the differences between WebAPI and WebAPI 2

    http://stackoverflow.com/questions/21298961/what-are-the-differences-between-webapi-and-webapi-2 Maj ...

  2. iOS开发-sqlite3使用

    SQLite3使用 SQLite简介 SQLite,是一款轻型的数据库,是遵守ACID的关系型数据库管理系统,它包含在一个相对小的C库中. SQLite3 在XCode工程中,打开targets,在B ...

  3. BZOJ 3130 二分+网络流

    思路: 不被题目忽悠就是思路 二分一下max 判一下等不等于最大流 搞定 7 9 1 1 2 3 1 3 3 2 3 3 3 4 2 3 5 2 3 6 1 4 7 2 5 7 2 6 7 2 这里有 ...

  4. 利用js与java交互

    为了方便网页和应用的交互,安卓系统WebView提供JavaScript网页脚本调用Java类方法的机制.只要调用addJavascriptInterface方法即可映射一个Java对象到JavaSc ...

  5. ListView中嵌套GridView点击事件

    做一个项目时,需要在ListView中嵌套GridView,因为ListView的每个条目中不一定出现GridView,那么问题来了,添加GridView的Item的点击事件后,有GridView出现 ...

  6. links[v1]

    justep core java Spring Boot ui5 template spring Cross-origin resource sharing 统一异常处理 数据库连接池的选择 Drui ...

  7. ORM原理

    原理: 1.实现JavaBean的属性到数据库表的字段的映射:        --通过配置文件将JavaBean的属性与数据库表的字段的关联起来 2.映射关系:   一对多,多对一等 持久层(Pers ...

  8. plsql 中如何清除曾经登录过的用户名

    tools(工具)---> preferences(首选项) ---> login history(登录历史) ---> history(历史) ---> 把你想要删除的删除

  9. neo4j nosql图数据库学习

    neo4j 文档:https://neo4j.com/docs/getting-started/current/cypher-intro/ 1.索引 # 给某类标签节点的属性添加索引 CREATE I ...

  10. 【Codeforces Round #422 (Div. 2) C】Hacker, pack your bags!(hash写法)

    接上一篇文章; 这里直接把左端点和右端点映射到vector数组上; 映射一个open和close数组; 枚举1..2e5 如果open[i]内有安排; 则用那个安排和dp数组来更新答案; 更新答案完之 ...