纯粹是为了改进牛吃草里的两圆交模板= =。

  代码如下:

  1. #include <stdio.h>
  2. #include <algorithm>
  3. #include <string.h>
  4. #include <vector>
  5. #include <math.h>
  6. using namespace std;
  7. const int N = + ;
  8. typedef long long ll;
  9. const double eps = 1e-;
  10. const double pi = acos(-1.0);
  11. double inf = ;
  12.  
  13. struct circle
  14. {
  15. double x,y,r;
  16. void read()
  17. {
  18. scanf("%lf%lf%lf",&x,&y,&r);
  19. }
  20. double calS()
  21. {
  22. return pi*r*r;
  23. }
  24. }c[];
  25.  
  26. double myabs(double x) {return x < ? -x : x;}
  27.  
  28. double get(circle c1,circle c2)
  29. {
  30. double a = c1.x, b = c1.y, R = c1.r;
  31. double x = c2.x, y = c2.y, r = c2.r;
  32. double dx = myabs(a-x), dy = myabs(b-y);
  33. double d = sqrt(dx*dx+dy*dy);
  34. if(d > R + r) return 0.0;
  35. if(R < r) swap(R,r);
  36. if(d < R-r) return pi*r*r;
  37. double A = 2.0*acos((R*R+d*d-r*r)/(2.0*R*d));
  38. double B = 2.0*acos((r*r+d*d-R*R)/(2.0*r*d));
  39. double s1 = 0.5*A*R*R + 0.5*B*r*r;
  40. double s2 = 0.5*R*R*sin(A) + 0.5*r*r*sin(B);
  41. return s1 - s2;
  42. }
  43.  
  44. int n;
  45. bool solve(circle now)
  46. {
  47. for(int i=;i<=n;i++)
  48. {
  49. if(get(now,c[i]) >= 0.5*c[i].calS()) ;
  50. else return ;
  51. }
  52. return ;
  53. }
  54.  
  55. int main()
  56. {
  57. int T;
  58. scanf("%d",&T);
  59. while(T--)
  60. {
  61. scanf("%d",&n);
  62. for(int i=;i<=n;i++) c[i].read();
  63. double ans = inf;
  64. for(int i=;i<=n;i++)
  65. {
  66. circle now = c[i];
  67. double L = , R = inf;
  68. int CNT = ;
  69. while(CNT--)
  70. {
  71. double mid = (L + R) / ;
  72. now.r = mid;
  73. if(solve(now)) R = mid;
  74. else L = mid;
  75. }
  76. ans = min(ans, R);
  77. }
  78. printf("%.4f\n",ans);
  79. }
  80. return ;
  81. }

HDU 3264 Open-air shopping malls ——(二分+圆交)的更多相关文章

  1. hdu 3264 Open-air shopping malls(圆相交面积+二分)

    Open-air shopping malls Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/ ...

  2. HDU 3467 Song of the Siren(圆交)

    Problem Description In the unimaginable popular DotA game, a hero Naga Siren, also known as Slithice ...

  3. HDU - 6167: Missile Interception (二分+圆的交)

    pro:二维平面上,给点N个导弹的初始位置,射出方向,速度.问你是找一点,可以从这一点向任意方向发出拦截导弹,速度未V,最小化最大拦截导弹的时间.  如果要拦截一个导弹,必须在导弹发射之后才可以发射拦 ...

  4. hdu3264Open-air shopping malls(二分)

    链接 枚举伞的圆心,最多只有20个,因为必须与某个现有的圆心重合. 然后再二分半径就可以了. #include <iostream> #include<cstdio> #inc ...

  5. hdu 3264 09 宁波 现场 E - Open-air shopping malls 计算几何 二分 圆相交面积 难度:1

    Description The city of M is a famous shopping city and its open-air shopping malls are extremely at ...

  6. HDU 3264/POJ 3831 Open-air shopping malls(计算几何+二分)(2009 Asia Ningbo Regional)

    Description The city of M is a famous shopping city and its open-air shopping malls are extremely at ...

  7. POJ 3831 &amp; HDU 3264 Open-air shopping malls(几何)

    题目链接: POJ:id=3831" target="_blank">http://poj.org/problem?id=3831 HDU:http://acm.h ...

  8. hdu 3264(枚举+二分+圆的公共面积)

    Open-air shopping malls Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/ ...

  9. hdu 3264 圆的交+二分

    Open-air shopping malls Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/ ...

随机推荐

  1. java下载多个文件文件

    第一步 将要下载的多个文件打包成ZIP格式 public String makeZip(List<String> path) throws IOException{ byte[] buff ...

  2. Override/implements methods 如何添加

    用过Eclipse 的ADT的都知道,要快速添加override或者implements方法,右键---Source---Override/Implements Method... 中文:右键---& ...

  3. ubuntu上的mysql数据库双机备份设置

    配置环境: myslq 5.5.3 + ubuntu server 12.04 一.配置MySQL主服务器(192.168.0.1) 1.增加一个账号专门用于同步 1 mysql>grant r ...

  4. jsonp的简单实现

    jsonp: function(url, data, callback){ if( wfQuery.isFunction(data) ){ callback = data; data = {}; } ...

  5. eclipse快捷键(转载)

    Ctrl+1 快速修复(最经典的快捷键,就不用多说了)Ctrl+D: 删除当前行 Ctrl+Alt+↓ 复制当前行到下一行(复制增加)Ctrl+Alt+↑ 复制当前行到上一行(复制增加)Alt+↓ 当 ...

  6. 【转】获取/设置IFRAME内对象元素的几种JS方法

    1.IE专用(通过frames索引形象定位): document.frames[i].document.getElementById('元素的ID'); 2.IE专用(通过IFRAME名称形象定位): ...

  7. 查看光纤卡wwn号【转载】

    转自:查看光纤卡wwn号windows操作系统下_朝晖_新浪博客http://blog.sina.com.cn/s/blog_4ce992f40101dxyv.html 查看光纤卡wwn号window ...

  8. springmvc json数据

    的 @RequestMapping("/getAllEdu") @ResponseBody public void getAllEdu(HttpServletRequest req ...

  9. zf-关于查询机把index.jsp换成index_new.jsp页面之后把功能链接都改成新页面的简单方法

    一开始我都是找action 然后一个一个的改 把onmousedown="goURL('index.jsp')" 改成 onmousedown="goURL('index ...

  10. 【学生成绩管理系统】 大二c语言作业

    几年前写的了,只能在命令行窗口运行,虽然比较挫,还是有一定参考价值... #include <cstdio> #include <conio.h> #include <i ...