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

    一.vue - 介绍 vue的作者叫尤雨溪,中国人.自认为很牛逼的人物,也是我的崇拜之神. 关于他本人的认知,希望大家读一下这篇关于他的文章,或许你会对语言,技术,产生浓厚的兴趣.https://mp ...

  2. sql server 用脚本管理作业

    转自:https://blog.csdn.net/yunye114105/article/details/6594826 摘要: 在SQL SERVER中用脚本管理作业,在绝大部分场景下,脚本都比UI ...

  3. drawable转mitmap 以及图片base64编码

    static Bitmap drawableToBitmap(Drawable drawable) // drawable 转换成bitmap { int width = drawable.getIn ...

  4. Deep Learning(3)算法简介

    查看最新论文 Yoshua Bengio, Learning Deep Architectures for AI, Foundations and Trends in Machine Learning ...

  5. 001-mybatis框架

    架构分析: 1. 读SqlMapConfig.xml. 当调用与数据库有关的操作的时候,会读SqlMapConfig.xml文件中的信息,里面配置了Mybatis的运行环境信息,加载mapper.xm ...

  6. vue-router的hash模式与history模式的对比

    Vue-router 中hash模式和history模式的关系在vue的路由配置中有mode选项 最直观的区别就是在url中 hash 带了一个很丑的 # 而history是没有#的mode:&quo ...

  7. nodejs+express工程 在npm install之后或使用npm install bootstrap命令安装bootstrap之后

    nodejs+express工程 在npm install之后或使用npm install bootstrap命令安装bootstrap之后引入bootstrap文件 如果你的静态资源存放在多个目录下 ...

  8. MySQL "tinyInt1isBit or tinyint(1)" 相关问题解析

    问题描述 tinyInt 的数据类型,在JAVA数据类型 和 MySQL的数据类型转换,要注意存储长度为 1 的情况.查询时,该字段对应的Java类型为Boolean 源数据: 读取后数据: 问题分析 ...

  9. 20159212杨翔实验一(熟悉Java开发环境)实验报告

     实验内容 1.使用JDK编译.运行简单的Java程序: 2.使用Eclipse 编辑.编译.运行.调试Java程序. 实验步骤与体会 一.命令行下Java程序开发 1.操作过程     在虚拟环境中 ...

  10. 2018-2019-1 20189215 《Linux内核原理与分析》第九周作业

    进程的切换和系统 <庖丁解牛>第八章书本知识总结 进程调度的时机都与中断相关,中断是程序执行过程中的强制性转移,转移到操作系统内核相应的处理程序. 软中断也叫异常,分为故障.退出和陷阱(自 ...