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. C#基础在using中创建对象

    在using中创建的对象的类必须是实现了IDispose接口的类,示例代码如下: static void Main(string[] args) { Method(); Console.WriteLi ...

  2. Python模块之pickle(列表,字典等复杂数据类型与二进制文件的转化)

    1.pickle模块简介 The pickle module implements binary protocols for serializing and de-serializing a Pyth ...

  3. php程序员面试经验

    面试是你进入公司的第一个关卡,面试过后还会有试用期.可有时候总有那么一些人对待面试完全没人任何防备. 如果你想进入一家优秀的企业,那么对于面试你一定要做好十足的准备.为什么说了:"将军不打没 ...

  4. Docker(四):Docker基本网络配置

    1.Libnetwork Libnetwork提出了新的容器网络模型简称为CNM,定义了标准的API用于为容器配置网络. CNM三个重要概念: 沙盒:一个隔离的网络运行环境,保存了容器网络栈的配置,包 ...

  5. lesson - 1 笔记 网络连接 /putty 密钥登陆

    ---笔记 一.网络连接配置 1. 查看电脑ip 地址: ifconfig -a  2. 自动获取ip 地址: dhclient   默认BOOTPROTO=dhcp  和真机同一网段 3. 手动配置 ...

  6. shiro Filter--拦截器

    一 shiro自带的filter:下面主要叙述顺序是 NameableFilter->OncePerRequestFilter->AdviceFilter->PathMatching ...

  7. APP开发选择什么框架好? 请看这里!

    背景 App的开发一般都需要满足Android和iOS两个系统环境,也就意味着一个App需要定制两套实现方案,造成开发成本和维护成本都很高.为了解决这个问题,最好的办法就是实现一套代码跨端运行,所以H ...

  8. python_第2课

    前言 回顾一下python+selenium基础,并整理相关知识点,分享给有需要,在前进道路上的朋友. 由于不是在python中敲的代码,有可能有缩进等相关错误,请自行检查 数据类型 #python中 ...

  9. JQuery 网页瞄点

    $("html,body").animate({ scrollTop: $("#Content1").offset().top }, 3000); 代码说明:h ...

  10. 前端js之JavaScript

    知识预览 一小知识 二 JavaScript的基础 BOM对象 DOM对象 实例练习 js拓展 小知识 核心(ECMAScript) 文档对象模型(DOM) Document object model ...