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.

题目大意:给n个互相相离的圆,要求以其中一个圆的圆点为中心,画一个大圆,这个大圆要覆盖这n个圆至少一半的面积,求这个大圆的最小半径。

思路:枚举圆心,二分半径判断是否符合条件即可。

代码(0MS):

 #include <cstdio>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cmath>
using namespace std; const int MAXN = ;
const double PI = * acos(0.0);
const double EPF = 1e-; double x[MAXN], y[MAXN], r[MAXN];
int n, T; double dist(double x1, double y1, double x2, double y2) {
int xx = x1 - x2, yy = y1 - y2;
return sqrt(xx * xx + yy * yy);
} double fusiform(double a, double c, double b) {
double angle = * acos((a * a + b * b - c * c) / ( * a * b));
double s1 = a * a * PI * (angle / ( * PI));
double s2 = a * a * sin(angle) / ;
return s1 - s2;
} bool common(double x1, double y1, double r1, double x2, double y2, double r2) {
double d = dist(x1, y1, x2, y2);
if(d >= r1 + r2) return false;
if(d <= fabs(r1 - r2)) {
if(r1 > r2) return true;
else return (r1 * r1 * >= r2 * r2);
}
double value = fusiform(r1, r2, d) + fusiform(r2, r1, d);
return value * >= r2 * r2 * PI;
} bool check(double ox, double oy, double rr) {
for(int i = ; i <= n; ++i)
if(!common(ox, oy, rr, x[i], y[i], r[i])) return false;
return true;
} double calc(double ox, double oy) {
double l = , r = ;
while(r - l > 1e-) {
double mid = (l + r) / ;
if(check(ox, oy, mid)) r = mid;
else l = mid;
}
return l;
} void solve() {
double ans = 1e100, value;
for(int i = ; i <= n; ++i) {
value = calc(x[i], y[i]);
ans = min(ans, value);
}
printf("%.4f\n", ans);
} int main() {
//cout<<PI<<endl;
scanf("%d", &T);
while(T--) {
scanf("%d", &n);
for(int i = ; i <= n; ++i) scanf("%lf%lf%lf", &x[i], &y[i], &r[i]);
solve();
}
}

HDU 3264/POJ 3831 Open-air shopping malls(计算几何+二分)(2009 Asia Ningbo Regional)的更多相关文章

  1. HDU 3269 P2P File Sharing System(模拟)(2009 Asia Ningbo Regional Contest)

    Problem Description Peer-to-peer(P2P) computing technology has been widely used on the Internet to e ...

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

  3. HDU 3265/POJ 3832 Posters(扫描线+线段树)(2009 Asia Ningbo Regional)

    Description Ted has a new house with a huge window. In this big summer, Ted decides to decorate the ...

  4. HDU 3260/POJ 3827 Facer is learning to swim(DP+搜索)(2009 Asia Ningbo Regional)

    Description Facer is addicted to a game called "Tidy is learning to swim". But he finds it ...

  5. HDU 3262/POJ 3829 Seat taking up is tough(模拟+搜索)(2009 Asia Ningbo Regional)

    Description Students often have problems taking up seats. When two students want the same seat, a qu ...

  6. HDU 3268/POJ 3835 Columbus’s bargain(最短路径+暴力枚举)(2009 Asia Ningbo Regional)

    Description On the evening of 3 August 1492, Christopher Columbus departed from Palos de la Frontera ...

  7. Open-air shopping malls(二分半径,两元交面积)

    http://acm.hdu.edu.cn/showproblem.php?pid=3264 Open-air shopping malls Time Limit: 2000/1000 MS (Jav ...

  8. HDU 3264 Open-air shopping malls ——(二分+圆交)

    纯粹是为了改进牛吃草里的两圆交模板= =. 代码如下: #include <stdio.h> #include <algorithm> #include <string. ...

  9. [hdu 3264] Open-air shopping malls(二分+两圆相交面积)

    题目大意是:先给你一些圆,你可以任选这些圆中的一个圆点作圆,这个圆的要求是:你画完以后.这个圆要可以覆盖之前给出的每一个圆一半以上的面积,即覆盖1/2以上每一个圆的面积. 比如例子数据,选左边还是选右 ...

随机推荐

  1. android软件开发之获取本地音乐属性

    歌曲的名称 :MediaStore.Audio.Media.TITLString tilte = cursor.getString(cursor.getColumnIndexOrThrow(Media ...

  2. mongo配置项说明

    mongo configure 配置文件   storage:     dbPath: mongod实例存储其数据的目录.     indexBuildRetry: 指定是否mongod在下次启动时重 ...

  3. Spring Cloud 微服务入门(一)--初识分布式及其发展历程

    分布式开发出现背景 当有计算机出现一段时间之后就开始有人去想如何将不同的电脑进行网络连接,而网络连接之后对于web的项目开发就探索所谓的分布式设计,同时人们也意识到重要的数据必须多份存在.所以分布式就 ...

  4. canvas绘制圆角头像

    如果你想绘制的网页包含一个圆弧形的头像的canvas图片,但是头像本身是正方形的,需要的方法如下:首先, 拿到头像在画布上的坐标和宽高:(具体怎么获取不在此做具体介绍) 使用canvas绘制圆弧动画 ...

  5. Cannot send session cache limiter - headers already sent问题

    在php.ini中将“always_populate_raw_post_data ”设置为“-1”,并重启

  6. 小白CSS学习日记-----杂乱无序记录(3)

    1.后代选择器 .antzone li { } class='antzone' 所有子孙后代中的li   2.子选择器 .antzone > li { } class='antzone' 的子一 ...

  7. sourcetree .git 强制忽略指定文件不提交

    在公司写项目,大部分都会用到 svn 或 git 提交代码到服务器.我们公司用的GIT,每个程序员有自己的独立分支,各写各的代码互不冲突,最终合并到主分支再解决相同代码冲突问题.这时候会遇到一些配置文 ...

  8. 使用 win10 的库来组织自己的同类文件

    库相当于虚拟目录,可以把不同的文件夹包含起来. 找起东西来不用东奔西跑了...

  9. HBase学习(一):认识HBase

    一.大数据发展背景 现今是数据飞速膨胀的大数据时代,大数据强调3V特征,即Volume(量级).Varity(种类)和Velocity(速度). ·Volume(量级):TB到ZB. ·Varity( ...

  10. Altium Designer 快捷键与技巧

    在PCB中: 布线过程中,换层快捷键:"Ctrl"  + "Shift" + "滚轮". 单独显示顶层或底层:按"SHIFT&qu ...