Open-air shopping malls

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 2458    Accepted Submission(s):
906

Problem Description
The city of M is a famous shopping city and its
open-air shopping malls are extremely attractive. During the tourist seasons,
thousands of people crowded into these shopping malls and enjoy the
vary-different shopping.

Unfortunately, the climate has changed little by
little and now rainy days seriously affected the operation of open-air shopping
malls—it’s obvious that nobody will have a good mood when shopping in the rain.
In order to change this situation, the manager of these open-air shopping malls
would like to build a giant umbrella to solve this problem.

These
shopping malls can be considered as different circles. It is guaranteed that
these circles will not intersect with each other and no circles will be
contained in another one. The giant umbrella is also a circle. Due to some
technical reasons, the center of the umbrella must coincide with the center of a
shopping mall. Furthermore, a fine survey shows that for any mall, covering half
of its area is enough for people to seek shelter from the rain, so the task is
to decide the minimum radius of the giant umbrella so that for every shopping
mall, the umbrella can cover at least half area of the mall.

 
Input
The input consists of multiple test cases.
The
first line of the input contains one integer T (1<=T<=10), which is the
number of test cases.
For each test case, there is one integer N
(1<=N<=20) in the first line, representing the number of shopping
malls.
The following N lines each contain three integers X,Y,R, representing
that the mall has a shape of a circle with radius R and its center is positioned
at (X,Y). X and Y are in the range of [-10000,10000] and R is a positive integer
less than 2000.
 
Output
For each test case, output one line contains a real
number rounded to 4 decimal places, representing the minimum radius of the giant
umbrella that meets the demands.
 
Sample Input
1
2
0 0 1
2 0 1
 
Sample Output
2.0822
 
Source
 
Recommend
lcy   |   We have carefully selected several similar
problems for you:  3268 3265 3269 3262 3263 
 
题意:给出一些圆,选择其中一个圆的圆心为圆心,然后画一个大圆,要求大圆最少覆盖每个圆的一半面积。求大圆最小时的半径。
 
枚举每个点,用二分求出需要的圆,更新最小值即可。 
其中用到了圆相交面积,可以参考这题: http://www.cnblogs.com/pshw/p/5711251.html
 
附上代码:
 
 #include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#define N 25 const double pi = acos(-1.0);
const double EPS = 1e-;
int n; double max(double a,double b)
{
return a>b?a:b;
} double min(double a,double b)
{
return a<b?a:b;
} struct Round
{
double x,y;
double r;
} rr[N],s; double dis(Round a, Round b) ///两点之间的长度
{
return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
} double solve(Round a, Round b) ///求两圆相交的面积
{
double d = dis(a, b);
if(d >= a.r + b.r)
return ;
else if(d <= fabs(a.r-b.r))
{
double r = a.r < b.r?a.r : b.r;
return pi * r * r;
}
double ang1 = acos((a.r * a.r + d * d - b.r * b.r) / 2.0 / a.r / d);
double ang2 = acos((b.r * b.r + d * d - a.r * a.r) / 2.0 / b.r / d);
double ret = ang1 * a.r * a.r + ang2 * b.r * b.r - d * a.r * sin(ang1);
return ret;
} bool check(Round s)
{
for(int i=; i<n; i++) ///大圆是否覆盖每个圆的一半面积
{
if(solve(s, rr[i]) * < pi * rr[i].r * rr[i].r)
return false; ///不满足直接返回
}
return true;
} double bin(double l, double r, Round s) ///二分,找出最小圆的半径
{
double mid;
while(fabs(l - r) >= EPS) ///精度划分
{
mid = (l + r) / ;
s.r = mid;
if(check(s)) ///满足返回的说明半径长度足够,有可能可以更短
r=mid;
else ///不满足返回的说明半径长度不够,需要更长
l=mid+EPS;
}
return mid;
} int main()
{
int T,i,j;
scanf("%d",&T);
while(T--)
{
scanf("%d",&n);
for(i=; i<n; i++)
scanf("%lf%lf%lf",&rr[i].x,&rr[i].y,&rr[i].r);
double ans = 1e10;
for(i=; i<n; i++)
{
s.x = rr[i].x;
s.y = rr[i].y;
double right = ;
for(j=; j<n; j++)
{
right = max(right, dis(s, rr[j]) + rr[j].r);
///以当前点为圆心,找出可以覆盖所有的圆面积的最长半径
}
ans = min(ans, bin(, right, s)); ///二分搜索,记录最小的圆的半径
}
printf("%.4f\n", ans);
}
return ;
}

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

  1. 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 ...

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

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

  3. HDU 3264 Open-air shopping malls (计算几何-圆相交面积)

    传送门:http://acm.hdu.edu.cn/showproblem.php?pid=3264 题意:给你n个圆,坐标和半径,然后要在这n个圆的圆心画一个大圆,大圆与这n个圆相交的面积必须大于等 ...

  4. [hdu 3264] Open-air shopping malls(二分+两圆相交面积)

    题目大意是:先给你一些圆,你可以任选这些圆中的一个圆点作圆,这个圆的要求是:你画完以后.这个圆要可以覆盖之前给出的每一个圆一半以上的面积,即覆盖1/2以上每一个圆的面积. 比如例子数据,选左边还是选右 ...

  5. HDU 3467 (求五个圆相交面积) Song of the Siren

    还没开始写题解我就已经内牛满面了,从晚饭搞到现在,WA得我都快哭了呢 题意: 在DotA中,你现在1V5,但是你的英雄有一个半径为r的眩晕技能,已知敌方五个英雄的坐标,问能否将该技能投放到一个合适的位 ...

  6. hdu 5120(2014北京—求圆相交)

    题意:求环的相交面积 思路: 通过画图可知,面积= 大圆相交面积 - 大小圆相交面积*2 + 小小圆相交面积  再通过圆相交模板计算即可 #include <iostream> #incl ...

  7. 【HDU 5858】Hard problem(圆部分面积)

    边长是L的正方形,然后两个半径为L的圆弧和中间直径为L的圆相交.求阴影部分面积. 以中间圆心为原点,对角线为xy轴建立直角坐标系. 然后可以联立方程解出交点. 交点是$(\frac{\sqrt{7} ...

  8. poj2546Circular Area(两圆相交面积)

    链接 画图推公式 这两种情况 都可用一种公式算出来 就是两圆都求出圆心角 求出扇形的面积减掉三角形面积 #include <iostream> using namespace std; # ...

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

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

随机推荐

  1. python基--re模块的使用

    正则表达式: 正则表达式本身是一种小型的.高度专业化的编程语言,然而在python中,通过内嵌集成re模块让调用者们可以直接调用来实现正则匹配.正则表达模式被变异成一系列的字节码,然后由C语言编写的 ...

  2. 跟我一起使用webpack给一个开源项目添加一个运行入口

    啦啦啦啦啦不要把webpack想的很高大上就放弃了探究的想法,其实webpack特别的平易近人,就是一个工具 今天看到了一个超级美丽的项目 你可以看到各种各样的口红色号,满屏的粉色,哇哇哇哇塞,美美哒 ...

  3. poj 2406 Power Strings(KMP入门,next函数理解)

    Power Strings Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 37685   Accepted: 15590 D ...

  4. 对List<Map<String, Object>>集合排序

    private void mySort(List<Map<String, Object>> list) { //list为待排序的集合,按SEQ字段排序 Comparator& ...

  5. [LeetCode] Evaluate Reverse Polish Notation [2]

    题目 Evaluate the value of an arithmetic expression in Reverse Polish Notation. Valid operators are +, ...

  6. C++通配符

    #include<iostream>using namespace std;bool PathernMatch(char *pat, char *str){ char *s = NULL; ...

  7. Eclipse创建jsp web项目

    Eclipse 是一个开放源代码的.基于Java的可扩展开发平台.就其本身而言,它只是一个框架和一组服务,用于通过插件组件构建开发环境.幸运的是,Eclipse 附带了一个标准的插件集,包括Java开 ...

  8. PYTHON网络爬虫与信息提取[正则表达式的使用](单元七)

    正则表达式由字符和操作符构成 . 表示任何单个字符 []字符集,对单个字符给出取值范围 [abc]或者关系  [a-z]表示 [^abc]表示非这里面的东西 非字符集 * 表示星号之前的字符出现0次或 ...

  9. 两种方法使vue实现jQuery调用

    引言 如果说vue是前端工程化使用较多的骨架,那么JavaScript就是我们的前端的细胞.MVVM模式让我们体验到前端开发的便携,无需再过多的考虑DOM的操作.而vue的渐进式开发(逐步引用组件,按 ...

  10. PyCharm2019 永久激活

    <!-- 2019激活码 2019-06-21新更新 --> D00F1BDTGF-eyJsaWNlbnNlSWQiOiJEMDBGMUJEVEdGIiwibGljZW5zZWVOYW1l ...