hdu 3264 09 宁波 现场 E - Open-air shopping malls 计算几何 二分 圆相交面积 难度:1
Description
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 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
Sample Input
2
0 0 1
2 0 1
Sample Output
#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的更多相关文章
- 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 ...
- hdu 3268 09 宁波 现场 I - Columbus’s bargain 读题 最短路 难度:1
Description On the evening of 3 August 1492, Christopher Columbus departed from Palos de la Frontera ...
- HDU 3264 Open-air shopping malls ——(二分+圆交)
纯粹是为了改进牛吃草里的两圆交模板= =. 代码如下: #include <stdio.h> #include <algorithm> #include <string. ...
- HDU 3264 Open-air shopping malls (计算几何-圆相交面积)
传送门:http://acm.hdu.edu.cn/showproblem.php?pid=3264 题意:给你n个圆,坐标和半径,然后要在这n个圆的圆心画一个大圆,大圆与这n个圆相交的面积必须大于等 ...
- 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 ...
- [hdu 3264] Open-air shopping malls(二分+两圆相交面积)
题目大意是:先给你一些圆,你可以任选这些圆中的一个圆点作圆,这个圆的要求是:你画完以后.这个圆要可以覆盖之前给出的每一个圆一半以上的面积,即覆盖1/2以上每一个圆的面积. 比如例子数据,选左边还是选右 ...
- hdu 3264 Open-air shopping malls(圆相交面积+二分)
Open-air shopping malls Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/ ...
- HDU 3467 (求五个圆相交面积) Song of the Siren
还没开始写题解我就已经内牛满面了,从晚饭搞到现在,WA得我都快哭了呢 题意: 在DotA中,你现在1V5,但是你的英雄有一个半径为r的眩晕技能,已知敌方五个英雄的坐标,问能否将该技能投放到一个合适的位 ...
- POJ 3831 & HDU 3264 Open-air shopping malls(几何)
题目链接: POJ:id=3831" target="_blank">http://poj.org/problem?id=3831 HDU:http://acm.h ...
随机推荐
- MySQL 数据库的主从配置
mysql主从配置.鄙人是在如下环境测试的: 主数据库所在的操作系统:win7 主数据库的版本:5.0 主数据库的ip地址:192.168.1.111 从数据库所在的操作系统:linux 从数据的版本 ...
- python re.sub 括号匹配替换匹配到的内容后接数字
如果代码为: text = re.sub(r'(?<=[{])([a-z]+)6(?=[}])', r'\13', text) 上面代码会报错,因为没有组合13,所以不能获得组合13的内容. 但 ...
- Dolls---hdu4160(最大匹配)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4160 有n个长方体形的娃娃:当长宽高都小于另一个的时候可以放进去,每一个里面最多放一个,问最优的套法下 ...
- 深入理解Docker容器执行引擎runC
1 简介 根据官方的定义:runC是一个根据OCI标准创建并运行容器的CLI tool. Docker就是基于runC创建的,简单地说,runC就是docker中最为核心的部分,容器的创建,运行,销毁 ...
- matplotlib常见绘图基础代码小结:折线图、散点图、条形图、直方图、饼图
一.折线图 二.散点图 三.条形图 四.直方图 五.饼图 一.折线图折线图用于显示随时间或有序类别的变化趋势 from matplotlib import pyplot as plt x = rang ...
- [Axiom3D]第一个Axiom3D程序
Axiom3D程序的基本渲染流程 #region Namespace Declarations using System; using System.Linq; using Axiom.Core; u ...
- python3 os.walk()使用
os.walk() 方法用于通过在目录树种游走输出在目录中的文件名,向上或者向下. 在Unix,Windows中有效. os.walk(top[, topdown=True[, onerror=Non ...
- 5.4 Components -- Wrapping Content in A Component(在组件中包裹内容)
1.有时候,你可能希望定义一个模板,它包裹其他模板提供的内容. 例如,假设我们创建一个blog-post模板,我们可以使用它来展现一个blog post: app/components/blog-po ...
- win7 +v Ubuntu 16.04 grub rescue 模式下修复 grub
前几天整理了下电脑的分区,合并并删除一些分区,结果导致 grub 被破坏了,Ubuntu进不去了,启动后直接进入了 rescure 模式.后来又折腾了下,终于修复好了,现总结一下. 先说一下我的系统环 ...
- 2018 Multi-University Training Contest 2 Solution
A - Absolute 留坑. B - Counting Permutations 留坑. C - Cover 留坑. D - Game puts("Yes") #include ...