Open-air shopping malls(二分半径,两元交面积)
http://acm.hdu.edu.cn/showproblem.php?pid=3264
Open-air shopping malls
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 2139 Accepted Submission(s): 775
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.
2
0 0 1
2 0 1
题意:给出很多的商店,要求一把打伞,伞的圆心要在某个商店中心,伞要覆盖每个圆至少一半的面积,求伞的最小半径
题解: 给的点一共20个,枚举不会超时,枚举每个圆心,然后二分半径找到最小的半径
下面是代码:
其中求两圆交面积的代码是复制的模板
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
#define eps 1e-6
#define N 25
#define INF 20000
#define pi acos(-1.0)
struct point{
double x, y;
point(){}
point(double _x, double _y) {
x = _x, y = _y;
} point operator - (point a){
return point(x-a.x, y-a.y);
} double operator * (point a){
return x*a.y - y*a.x;
} double len(){
return sqrt(x*x+y*y);
}
};
struct circle{
point c;
double r;
};
circle cir[N];
int n; double dist(point a, point b)
{
return (a-b).len();
} double area_cir_to_cir(circle a,circle b)
{
double d=dist(a.c,b.c),r1=a.r,r2=b.r,r;
if (r1+r2<=d) { return 0.0; }
else if (fabs(r1-r2)>=d) {
r=min(r1,r2);
return pi*r*r;
}
else {
double a1=(r1*r1+d*d-r2*r2)/(*r1*d);
double a2=(r2*r2+d*d-r1*r1)/(*r2*d);
a1=*acos(a1); a2=*acos(a2);
return (r1*r1*(a1-sin(a1))+r2*r2*(a2-sin(a2)))*0.5;
}
} bool check(circle a, circle b)
{
double s1 = area_cir_to_cir(a, b);
double s2 = pi*b.r*b.r;
return s1* > s2-eps;
}//函数重载 bool check(point o, double r)
{
circle t;
t.c = o, t.r = r;
for(int i = ; i < n; i++)
if(!check(t, cir[i]))return false;
return true;
} double solve(int id)
{
point o = cir[id].c;
double l = , r = INF;
while(fabs(l-r) > eps)
{
double m = 0.5*(l+r);
if(check(o, m)) r = m;
else l = m;
}
return l;
} int main()
{
int T;
scanf("%d", &T);
while(T--)
{
scanf("%d", &n);
for(int i = ; i < n; i++)
scanf("%lf %lf %lf", &cir[i].c.x, &cir[i].c.y, &cir[i].r);
double ans = INF;
for(int i = ; i < n; i++)
ans = min(ans, solve(i));
printf("%.4f\n", ans);
}
}
Open-air shopping malls(二分半径,两元交面积)的更多相关文章
- hdu3264Open-air shopping malls(二分)
链接 枚举伞的圆心,最多只有20个,因为必须与某个现有的圆心重合. 然后再二分半径就可以了. #include <iostream> #include<cstdio> #inc ...
- HDU 3264 Open-air shopping malls (计算几何-圆相交面积)
传送门:http://acm.hdu.edu.cn/showproblem.php?pid=3264 题意:给你n个圆,坐标和半径,然后要在这n个圆的圆心画一个大圆,大圆与这n个圆相交的面积必须大于等 ...
- HDU 3264/POJ 3831 Open-air shopping malls(计算几何+二分)(2009 Asia Ningbo Regional)
Description The city of M is a famous shopping city and its open-air shopping malls are extremely at ...
- hdu 3264 Open-air shopping malls(圆相交面积+二分)
Open-air shopping malls Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/ ...
- 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 ...
- POJ 3831 & HDU 3264 Open-air shopping malls(几何)
题目链接: POJ:id=3831" target="_blank">http://poj.org/problem?id=3831 HDU:http://acm.h ...
- UVALive - 6572 Shopping Malls floyd
题目链接: http://acm.hust.edu.cn/vjudge/problem/48416 Shopping Malls Time Limit: 3000MS 问题描述 We want to ...
- hdu 3264(枚举+二分+圆的公共面积)
Open-air shopping malls Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/ ...
- HDU 5130 Signal Interference --计算几何,多边形与圆的交面积
题意: 求所有满足PB <= k*PA 的P所在区域与多边形的交面积. 解法: 2014广州赛区的银牌题,当时竟然没发现是圆,然后就没做出来,然后就gg了. 圆的一般式方程: 设A(x1,y1) ...
随机推荐
- linux下PHP后台配置极光推送问题
一.composer.json配置注意空格 按照极光推送官网所述,在composer.json下写入: "require": { "jpush/jpush": ...
- VM虚拟机连Linux黑屏问题
在尝试了关闭VM的加速3D图形后,若仍黑屏(但是挂起时却能显示),可以尝试在以管理员身份cmd中输入netsh winsock reset,重启后可以恢复正常.这个问题似乎与网络某个端口有关,我上次打 ...
- 解决WebService/WCF调用时报错"服务器提交了协议冲突. Section=ResponseStatusLine"问题
今天更新了一个网站,新增了一个页面,调用WebService,在测试环境好好的,部署到正式环境后就莫名报错: 服务器提交了协议冲突. Section=ResponseStatusLine 网上查了好多 ...
- XE10 clientDataset 访问 DataSnap 服务端报错问题,锲而不舍找方法,终于解决了
1. 开发环境说明:win 10 下安装了XE10.2和Delphi7 2.按照网上datasnap 三层与使用xe10 自带的samples 的例子,访问数据库都要报莫名的地址错误,这个太不人性化: ...
- [C/C++语言标准] ISO C99/ ISO C11/ ISO C++11/ ISO C++14 Downloads
语言法典,C/C++社区人手一份,技术讨(hu)论(peng)必备 ISO IEC C99 https://files.cnblogs.com/files/racaljk/ISO_C99.pdf IS ...
- bzoj 3331: [BeiJing2013]压力
Description 如今,路由器和交换机构建起了互联网的骨架.处在互联网的骨干位置的 核心路由器典型的要处理100Gbit/s的网络流量.他们每天都生活在巨大的压力 之下. 小强建立了一个模型.这 ...
- 【quickhybrid】iOS端的项目实现
前言 18年元旦三天内和朋友突击了下,勉强是将雏形做出来了,后续的API慢慢完善.(当然了,主力还是那个朋友,本人只是初涉iOS,勉强能看懂,修修改改而已) 大致内容如下: JSBridge核心交互部 ...
- FPGA设计思想与技巧(转载)
题记:这个笔记不是特权同学自己整理的,特权同学只是对这个笔记做了一下完善,也忘了是从那DOWNLOAD来的,首先对整理者表示感谢.这些知识点确实都很实用,这些设计思想或者也可以说是经验吧,是很值得每一 ...
- springBoot系列教程04:mybatis及druid数据源的集成及查询缓存的使用
首先说下查询缓存:查询缓存就是相同的数据库查询请求在设定的时间间隔内仅查询一次数据库并保存到redis中,后续的请求只要在时间间隔内都直接从redis中获取,不再查询数据库,提高查询效率,降低服务器负 ...
- thinkphp 官方文件执行引入流程
官方手册上的执行流程图: 系统流程 用户URL请求 调用应用入口文件(通常是网站的index.php) 载入框架入口文件(ThinkPHP.php) 记录初始运行时间和内存开销 系统常量判断及定义 载 ...