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

Problem 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

题意:给出很多的商店,要求一把打伞,伞的圆心要在某个商店中心,伞要覆盖每个圆至少一半的面积,求伞的最小半径

题解: 给的点一共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(二分半径,两元交面积)的更多相关文章

  1. hdu3264Open-air shopping malls(二分)

    链接 枚举伞的圆心,最多只有20个,因为必须与某个现有的圆心重合. 然后再二分半径就可以了. #include <iostream> #include<cstdio> #inc ...

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

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

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

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

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

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

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

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

  7. UVALive - 6572 Shopping Malls floyd

    题目链接: http://acm.hust.edu.cn/vjudge/problem/48416 Shopping Malls Time Limit: 3000MS 问题描述 We want to ...

  8. hdu 3264(枚举+二分+圆的公共面积)

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

  9. HDU 5130 Signal Interference --计算几何,多边形与圆的交面积

    题意: 求所有满足PB <= k*PA 的P所在区域与多边形的交面积. 解法: 2014广州赛区的银牌题,当时竟然没发现是圆,然后就没做出来,然后就gg了. 圆的一般式方程: 设A(x1,y1) ...

随机推荐

  1. Redis分布式集群搭建

    Redis集群架构图 上图蓝色为redis集群的节点. 节点之间通过ping命令来测试连接是否正常,节点之间没有主区分,连接到任何一个节点进行操作时,都可能会转发到其他节点. 1.Redis的容错机制 ...

  2. lesson - 3 ls /cd /path /alias /快捷键

    内容概要: 1. 命令ls -l   详细信息-a  查看隐藏的文件或目录-d   只看目录本身,不列出目录下面的文件和目录-t 以时间先后排序 2  目录结构/bin, /sbin, /usr/bi ...

  3. Elasticsearch索引自动删除

    简介 脚本分2部分,1部分查找符合条件的索引名,2脚本调用1脚本,进行删除操作 脚本 查找符合条件的,默认大于30天 # coding:utf-8 __author__ = 'Jipu FANG' f ...

  4. 文档对象模型(DOM),你只需知道这些就够了!

    官方定义--应用程序编程接口(API) 文档对象模型是用于HTML和XML文档的应用程序编程接口,它定义文档的逻辑结构,以及访问和操作文档的方式. "The Document Object ...

  5. Handwritten Parsers & Lexers in Go (翻译)

    用go实现Parsers & Lexers 在当今网络应用和REST API的时代,编写解析器似乎是一种垂死的艺术.你可能会认为编写解析器是一个复杂的工作,只保留给编程语言设计师,但我想消除这 ...

  6. redis资料收集

    http://www.runoob.com/redis/redis-sets.html  redis set 使用 https://www.cnblogs.com/wanzaixiaoxin/p/49 ...

  7. C# winFrom窗体设计问题-部分文件打不开窗体设计器 变成类.cs

    https://zhidao.baidu.com/question/1513483178103163220.html C# winform程序设计的时候,出现了问题.默认主窗体form1(改名form ...

  8. 简单搭建ES6的环境

    一.兼容情况 说到ECMAScript6,顺便提一下ECMAScript5,先看一下ES5的兼容情况.ES5浏览器支持情况: Opera 11.60:Internet Explorer 9*:Fire ...

  9. spring boot RESTFul API拦截 以及Filter和interceptor 、Aspect区别

    今天学习一下RESTFul api拦截 大概有三种方式 一.通过Filter这个大家很熟悉了吧,这是java规范的一个过滤器,他会拦截请求.在springboot中一般有两种配置方式. 这种过滤器拦截 ...

  10. golang map

    Our friend Monk has been made teacher for the day today by his school professors . He is going to te ...