题面

题意:给你n个圆,每个圆有一个权值,你可以选择一个点,可以获得覆盖这个点的圆中,权值最大的m个的权值,问最多权值是多少

题解:好像是叙利亚的题....我们画画图就知道,我们要找的就是圆与圆交的那部分里面的点,我们再仔细看看,

2个圆的交点一定在啊!

别急啊,两个圆包含了,都是交点,取哪呢?当然小圆圆心就够了啊(圆又不多,写的时候直接把所有的圆心都丢进去了)

然后枚举判断每个点有没有被在m个圆中就行了,这里维护最大的m个,用个堆就好了

  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. typedef long double ld;
  4. const ld eps = 1e-;
  5. int dcmp(ld x)
  6. {
  7. if(fabs(x) < eps) return ;
  8. return x < ? - : ;
  9. }
  10. ld sqr(ld x) { return x * x; }
  11. struct Point
  12. {
  13. ld x, y;
  14. Point(ld x = , ld y = ):x(x), y(y) {}
  15. };
  16. Point operator - (const Point& A, const Point& B)
  17. {
  18. return Point(A.x - B.x, A.y - B.y);
  19. }
  20. bool operator == (const Point& A, const Point& B)
  21. {
  22. return dcmp(A.x - B.x) == && dcmp(A.y - B.x) == ;
  23. }
  24. ld Dot(const Point& A, const Point& B)
  25. {
  26. return A.x * B.x + A.y * B.y;
  27. }
  28. ld dis(Point a,Point b)
  29. {
  30. return sqrt(sqr(a.x-b.x)+sqr(a.y-b.y));
  31. }
  32. ld Length(const Point& A) { return sqrt(Dot(A, A)); }
  33. ld angle(Point v) { return atan2(v.y, v.x); }
  34. struct Circle
  35. {
  36. Point c;
  37. ld r,v;
  38. Circle() {}
  39. Circle(Point c, ld r):c(c), r(r) {}
  40. inline Point point(double a)
  41. {
  42. return Point(c.x+cos(a)*r, c.y+sin(a)*r);
  43. }
  44. }a[];
  45. int getCircleCircleIntersection(Circle C1, Circle C2,Point &t1,Point &t2)
  46. {
  47. ld d = Length(C1.c - C2.c);
  48. if(dcmp(d) == )
  49. {
  50. if(dcmp(C1.r - C2.r) == ) return -;
  51. return ;
  52. }
  53. if(dcmp(C1.r + C2.r - d) < ) return ;
  54. if(dcmp(fabs(C1.r-C2.r) - d) > ) return ;
  55. ld a = angle(C2.c - C1.c);
  56. ld da = acos((C1.r*C1.r + d*d - C2.r*C2.r) / (*C1.r*d));
  57. Point p1 = C1.point(a-da), p2 = C1.point(a+da);
  58. t1=p1;
  59. if(p1 == p2) return ;
  60. t2=p2;
  61. return ;
  62. }
  63. Point jd[];
  64. ld ans,sum;
  65. int n,m,T,tot;
  66. priority_queue<int,vector<int>,greater<int> >q;
  67. int main()
  68. {
  69. scanf("%d",&T);
  70. while (T--)
  71. {
  72. tot=;
  73. ans=;
  74. scanf("%d%d",&n,&m);
  75. for (int i=;i<=n;i++) scanf("%Lf%Lf%Lf%Lf",&a[i].c.x,&a[i].c.y,&a[i].r,&a[i].v);
  76. for (int i=;i<=n;i++)
  77. for (int j=i+;j<=n;j++)
  78. {
  79. Point t1,t2;
  80. int why=getCircleCircleIntersection(a[i],a[j],t1,t2);
  81. if (why==)
  82. {
  83. tot++;
  84. jd[tot]=t1;
  85. }else
  86. if (why==)
  87. {
  88. tot++;jd[tot]=t1;
  89. tot++;jd[tot]=t2;
  90. }
  91. }
  92. for (int i=;i<=n;i++)
  93. {
  94. tot++;
  95. jd[tot]=a[i].c;
  96. }
  97. for (int i=;i<=tot;i++)
  98. {
  99. for (int j=;j<=n;j++)
  100. if (dcmp(dis(jd[i],a[j].c)-a[j].r)<=)
  101. {
  102. q.push(a[j].v);
  103. if ((int)q.size()>m) q.pop();
  104. }
  105. sum=;
  106. while (!q.empty()) sum+=q.top(),q.pop();
  107. ans=max(ans,sum);
  108. }
  109. printf("%.Lf\n",ans);
  110. }
  111. }

Gym-101915B Ali and Wi-Fi 计算几何 求两圆交点的更多相关文章

  1. POJ 2546 &amp; ZOJ 1597 Circular Area(求两圆相交的面积 模板)

    题目链接: POJ:http://poj.org/problem? id=2546 ZOJ:problemId=597" target="_blank">http: ...

  2. ZOJ 1280 Interesting Lines | 求两直线交点

    原题: 求两直线交点 思路借鉴于:http://blog.csdn.net/zxy_snow/article/details/6341282 感谢大佬 #include<cstdio> # ...

  3. hdu 2857:Mirror and Light(计算几何,点关于直线的对称点,求两线段交点坐标)

    Mirror and Light Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) ...

  4. hdu5858 Hard problem(求两圆相交面积)

    题目传送门 Hard problem Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Other ...

  5. 求两圆相交部分面积(C++)

    已知两圆圆心坐标和半径,求相交部分面积: #include <iostream> using namespace std; #include<cmath> #include&l ...

  6. UVa 10674 (求两圆公切线) Tangents

    题意: 给出两个圆的圆心坐标和半径,求这两个圆的公切线切点的坐标及对应线段长度.若两圆重合,有无数条公切线则输出-1. 输出是按照一定顺序输出的. 分析: 首先情况比较多,要一一判断,不要漏掉. 如果 ...

  7. Gym-101158J Cover the Polygon with Your Disk 计算几何 求动圆与多边形最大面积交

    题面 题意:给出小于10个点形成的凸多边形 和一个半径为r 可以移动的圆 求圆心在何处的面积交最大,面积为多少 题解:三分套三分求出圆心位置,再用圆与多边形面积求交 #include<bits/ ...

  8. hdu 5120 (求两圆相交的面积

    题意:告诉你两个圆环,求圆环相交的面积. /* gyt Live up to every day */ #include<cstdio> #include<cmath> #in ...

  9. [poj] 1269 [zoj] 1280 Interesting Lines || 求两直线交点

    POJ原题 ZOJ原题 多组数据.每次给出四个点,前两个点确定一条直线,后两个点确定一条直线,若平行则输出"NONE",重合输出"LINE",相交输出" ...

随机推荐

  1. 后端springmvc,前端html5的FormData实现文件断点上传

    前言 最近项目中有使用到文件断点上传,得空便总结总结,顺便记录一下,毕竟“好记性不如烂笔头”. 后端代码: package com.test.controller; import java.io.Bu ...

  2. 努比亚 Z17s (Nubia NX595J) 解锁BootLoader 并刷入recovery ROOT

    首先下载好工具链接:https://pan.baidu.com/s/1nw7BoZB 密码:zuun 备用下载链接:https://pan.baidu.com/s/1c3mUQGg 本篇教程教你如何傻 ...

  3. 【Linux】七种运行级别

    运行级别:即系统的运行模式. 级别类型: 0:关机状态. 1:单用户模式. 2:字符界面的多用户模式(不支持网络). 3:字符界面的多用户模式(运行最完整的模式). 4:未分配使用,系统保留. 5:图 ...

  4. C#使用各种时间戳及转换

    /// <summary> /// DateTime时间格式转换为13位带毫秒的Unix时间戳 /// </summary> /// <param name=" ...

  5. HDU_1850_nim游戏

    Being a Good Boy in Spring Festival Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32 ...

  6. monad - the Category hierachy

    reading the "The Typeclassopedia" by Brent Yorgey in Monad.Reader#13 ,and found that " ...

  7. 关于MySQL,Oracle和SQLServer的特点以及之间区别

    关系型数据库:是指采用了关系模型来组织数据的数据库.简单来说,关系模型指的就是二维表格模型,而一个关系型数据库就是由二维表及其之间的联系组成的一个数据组织. 非关系型数据库:非关系型数据库严格上说不是 ...

  8. 使用.Net Core RT 标准动态库

    这个文档可以引导你如何通过CoreRT生成一个原生标准的系统动态库让其他编程语言调用. CoreRT 可以构建静态库, 这些库可以在编译时链接或者也可以构建运行时所需的共享库, 创建一个支持CoreR ...

  9. S-HR界面控件赋值取值

    属性值: this.getField("entrys.variationReason").shrPromptBox("getValue").name

  10. [luogu1129 ZJOI2007] 矩阵游戏 (二分图最大匹配)

    传送门 Description Input Output Sample Input 2 2 0 0 0 1 3 0 0 1 0 1 0 1 0 0 Sample Output No Yes HINT ...