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. lesson - 12 Linux系统日常管理1

    监控系统状态 – w, vmstat命令w, uptimesystem load averages 单位时间段内活动的进程数 查看cpu的个数和核数vmstat 1vmstat 1 10vmstat各 ...

  2. oracle12c_安装3——部署

    数据库安装后需要根据实际情况修改相关参数. 1.生成pfile以防万一. SQL> create pfile from spfile; 2.修改内存参数 只要设置MEMORY_MAX_TARGE ...

  3. 记录Mac下安装pyenv时所遇到的问题

    http://blog.csdn.net/foryouslgme/article/details/51683654  

  4. datatable使用笔记

    这是一个使用datatable的jsp文件实例,实现了点击单元格后编辑单元格所在行的内容. <%@ page pageEncoding="UTF-8"%> <!D ...

  5. Python文件读写 - 读一个文件所有行,加工后写另一个文件

    #Filename: file_read_and_write.py #打开文件,cNames读取所有行,储存在列表中,循环对每一行在起始处加上序号1,2,3,4 with open(r'file/co ...

  6. Java的虚方法

    虚方法出现在Java的多态特性中, 父类与子类之间的多态性,对父类的函数进行重新定义.如果在子类中定义某方法与其父类有相同的名称和参数,我们说该方法被重写 (Overriding).在Java中,子类 ...

  7. IO流之字节流知识总结

    IO流分为字符流和字节流. 字节流;可以读取任何文件,电脑以字节的方式储存 字符流:用来读取字符. 下面是我总结的思维导图. 相关练习代码 public class Demo { @Test publ ...

  8. vexx 邀请码 送3个比特龙

    错过了比特币的行情,注册获取3个原始比特币分叉币,比特龙. 目前10元一个,送3个币.类似于股票IPO,第一天一般会冲高十几倍,建议第一天就卖. 如果看好就继续持有吧. 放心是送的不用钱的. 注册网址 ...

  9. 通俗易懂的信息熵与信息增益(IE, Information Entropy; IG, Information Gain)

    信息熵与信息增益(IE, Information Entropy; IG, Information Gain) 信息增益是机器学习中特征选择的关键指标,而学习信息增益前,需要先了解信息熵和条件熵这两个 ...

  10. EditTable-V1.0--续集

    上一个功能有点少,这个V1.0版本是最小集合的. ================================= 双击单元格编辑,可以添加,删除单元格.并且保持相邻单元格不同的背景色. 引用了“M ...