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
 
计算圆相交面积(两圆扇形-中间的四边形),从所有圆圆心出发,二分求直径,然后选择最小即可
这是萌萌smilewsw代码: 
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#define eps 1e-10
#define PI acos(-1.0)
using namespace std;
struct point
{
double x,y;
};
struct circle
{
point c;
double r;
}ci[50];
double dis(point p1,point p2)
{
return sqrt((p1.x-p2.x)*(p1.x-p2.x)+(p1.y-p2.y)*(p1.y-p2.y));
}
double area(point p,double R,circle a)
{ double d=dis(p,a.c),pp;
double sa=0,ang1,ang2;
ang1=acos((a.r*a.r+d*d-R*R)/(2*a.r*d));
ang2=acos((R*R+d*d-a.r*a.r)/(2*R*d));
pp=R*sin(ang2);
sa=ang1*a.r*a.r+ang2*R*R-pp*d;
return sa;
}
double qsearch(point p,circle a)
{
double d=dis(p,a.c);
double l=d,r=sqrt(d*d+a.r*a.r),mid;
double ans=PI*a.r*a.r/2;
while(l+eps<r)
{
mid=(l+r)/2;
if(fabs(area(p,mid,a)-ans)<eps)
return mid;
else if(ans<area(p,mid,a))
r=mid;
else
l=mid;
}
return l;
}
int main()
{
int t,n;
point p;
circle a;
p.x=2,p.y=0;
a.c.x=0,a.c.y=0,a.r=1;
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
for(int i=0;i<n;i++)
scanf("%lf%lf%lf",&ci[i].c.x,&ci[i].c.y,&ci[i].r);
double minn;
for(int i=0;i<n;i++)
{
double maxn=ci[i].r/sqrt(2.0);
for(int j=0;j<n;j++)
{
if(i==j) continue;
maxn=max(maxn,qsearch(ci[i].c,ci[j]));
}
if(i==0)
minn=maxn;
else
minn=min(minn,maxn);
}
printf("%.4f\n",minn);
}
return 0;
}

  

hdu 3264 09 宁波 现场 E - Open-air shopping malls 计算几何 二分 圆相交面积 难度:1的更多相关文章

  1. hdu 3262 09 宁波 现场 C - Seat taking up is tough 暴力 难度:0

    Description Students often have problems taking up seats. When two students want the same seat, a qu ...

  2. hdu 3268 09 宁波 现场 I - Columbus’s bargain 读题 最短路 难度:1

    Description On the evening of 3 August 1492, Christopher Columbus departed from Palos de la Frontera ...

  3. HDU 3264 Open-air shopping malls ——(二分+圆交)

    纯粹是为了改进牛吃草里的两圆交模板= =. 代码如下: #include <stdio.h> #include <algorithm> #include <string. ...

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

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

  5. hdu 3696 10 福州 现场 G - Farm Game DP+拓扑排序 or spfa+超级源 难度:0

    Description “Farm Game” is one of the most popular games in online community. In the community each ...

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

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

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

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

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

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

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

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

随机推荐

  1. talib 中文文档(三):talib 方法大全

    Function API Examples Similar to TA-Lib, the function interface provides a lightweight wrapper of th ...

  2. Qt::浅谈信号槽连接,参数在多线程中的使用

    Qt的信号槽有五种连接方式定义在enum Qt::ConnectionType,下面简单介绍 Qt::AutoConnection:自动判断连接方式,如果信号发送对象和执行槽对象在同一线程,那么等于Q ...

  3. Linux系统——FTP

    FTP连接及传输模式1. 控制连接:TCP21,用于发送FTP命令信息2. 数据连接:TCP20,用于上传.下载数据3. 数据连接的建立类型:(1)主动模式:服务器制动发起数据连接首先由客户端向服务端 ...

  4. zw版【转发·台湾nvp系列Delphi例程】HALCON MoveRectangle2

    zw版[转发·台湾nvp系列Delphi例程]HALCON MoveRectangle2 procedure TForm1.Button1Click(Sender: TObject);var img ...

  5. 587. Erect the Fence(凸包算法)

    问题 给定一群树的坐标点,画个围栏把所有树围起来(凸包). 至少有一棵树,输入和输出没有顺序. Input: [[1,1],[2,2],[2,0],[2,4],[3,3],[4,2]] Output: ...

  6. sysctl.conf文件详解

    本文转自:http://www.cnblogs.com/Rosanna/p/3446557.html 使文件立刻生效命令:/sbin/sysctl -p /proc/sys目录下存放着大多数内核参数, ...

  7. centos配置用户级别的jdk的环境变量

    前面讲解了centos配置jdk的环境变量 的root级别的jdk配置 ,这里讲解用户级别的jdk配置. 在用户的当前目录下,如下,有四个隐藏的文件,文件打头是.bash******: 1.编辑.ba ...

  8. Vue-cli proxyTable 解决开发环境的跨域问题

    Vue-cli proxyTable 解决开发环境的跨域问题 proxyTable: { '/list': { target: 'http://api.xxxxxxxx.com', pathRewri ...

  9. StarUML激活

    感谢  http://blog.csdn.net/mergades/article/details/46662413 1,打开对应 mac版本的安装包位置,在对应目录/Applications/Sta ...

  10. HTTP从入门到入土(2)——HTTP协议发展历史

    HTTP协议的发展历史 HTTP/0.9 0.9版本是第一个定稿的HTTP版本,相对较为简陋.它有以下特点: 只有一个命令GET 没有header等描述数据的信息 服务器发送完毕,就关闭TCP连接 注 ...