hdu 3264 Open-air shopping malls(圆相交面积+二分)
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
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.
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.
number rounded to 4 decimal places, representing the minimum radius of the giant
umbrella that meets the demands.
其中用到了圆相交面积,可以参考这题: 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(圆相交面积+二分)的更多相关文章
- 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 ...
- hdu5858 Hard problem(求两圆相交面积)
题目传送门 Hard problem Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Other ...
- HDU 3264 Open-air shopping malls (计算几何-圆相交面积)
传送门:http://acm.hdu.edu.cn/showproblem.php?pid=3264 题意:给你n个圆,坐标和半径,然后要在这n个圆的圆心画一个大圆,大圆与这n个圆相交的面积必须大于等 ...
- [hdu 3264] Open-air shopping malls(二分+两圆相交面积)
题目大意是:先给你一些圆,你可以任选这些圆中的一个圆点作圆,这个圆的要求是:你画完以后.这个圆要可以覆盖之前给出的每一个圆一半以上的面积,即覆盖1/2以上每一个圆的面积. 比如例子数据,选左边还是选右 ...
- HDU 3467 (求五个圆相交面积) Song of the Siren
还没开始写题解我就已经内牛满面了,从晚饭搞到现在,WA得我都快哭了呢 题意: 在DotA中,你现在1V5,但是你的英雄有一个半径为r的眩晕技能,已知敌方五个英雄的坐标,问能否将该技能投放到一个合适的位 ...
- hdu 5120(2014北京—求圆相交)
题意:求环的相交面积 思路: 通过画图可知,面积= 大圆相交面积 - 大小圆相交面积*2 + 小小圆相交面积 再通过圆相交模板计算即可 #include <iostream> #incl ...
- 【HDU 5858】Hard problem(圆部分面积)
边长是L的正方形,然后两个半径为L的圆弧和中间直径为L的圆相交.求阴影部分面积. 以中间圆心为原点,对角线为xy轴建立直角坐标系. 然后可以联立方程解出交点. 交点是$(\frac{\sqrt{7} ...
- poj2546Circular Area(两圆相交面积)
链接 画图推公式 这两种情况 都可用一种公式算出来 就是两圆都求出圆心角 求出扇形的面积减掉三角形面积 #include <iostream> using namespace std; # ...
- hdu 3264(枚举+二分+圆的公共面积)
Open-air shopping malls Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/ ...
随机推荐
- 系统日志和内核消息 $ dmesg$ less /var/log/messages$ less /var/log/secure$ less /var/log/auth
查看错误和警告消息,比如看看是不是很多关于连接数过多导致? 看看是否有硬件错误或文件系统错误? 分析是否能将这些错误事件和前面发现的疑点进行时间上的比对.
- 怎样判断一个exe可执行程序(dll文件)是32位的还是64位的
看到一个比较简单粗暴的方式,做个记录. 直接用记事本或者notepad++(文本编辑软件都可)打开exe文件(dll文件), 会有很多乱码,接下来只需要在第二段中找到PE两个字母,在其后的不远出会出现 ...
- Python操作SQLite数据库的方法详解
Python操作SQLite数据库的方法详解 本文实例讲述了Python操作SQLite数据库的方法.分享给大家供大家参考,具体如下: SQLite简单介绍 SQLite数据库是一款非常小巧的嵌入式开 ...
- excel怎么制作三维圆环图表
excel怎么制作三维圆环图表 excel怎么制作三维圆环图表?excel中想要制作一个三维圆环图表,该怎么制作呢?下面我们就来看看详细的教程,很简单,在Excel中,可以通过自带的圆环图功能生成二维 ...
- jquery 设置 html标签响应式布局
function sWidth() {//计算当前设备宽度 var widthSize; if ($(window).width() <= 640) { widthSize = $(window ...
- win下在虚拟机安装CentOS 7 Linux系统
准备: CentOS 7下载地址(我下的是everthing版本):https://www.centos.org/download/ 一.首先下载安装虚拟机VMware 地址官网下载即可. 二.安装操 ...
- UIImageView添加圆角
最直接的方法就是使用如下属性设置: 1 2 3 imgView.layer.cornerRadius = 10; // 这一行代码是很消耗性能的 imgView.clipsToBounds = YES ...
- POJ3614 [USACO07NOV]防晒霜Sunscreen
Sunscreen Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 9333 Accepted: 3264 Descrip ...
- 如何合并两个git commit
把你的修改stage之后运行: git rebase -i HEAD~2 然后把第二行的pick改成squash就ok啦 note: 同理,如果要合并多个commit,把后面的2改成你想要合并的com ...
- PHP学习(mysqli函数)
php是一种运行在服务器端的程序语言,用于生产动态网页内容.特点:开源,简单,易上手,跨平台(windows,linux),占用资源少,尤其适合中小型应用开发.(微博,微信,论坛等等)一,搭建软件环境 ...