hdu 3264(枚举+二分+圆的公共面积)
Open-air shopping malls
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 2344 Accepted Submission(s): 866
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.
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.
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.
2
0 0 1
2 0 1
#include<stdio.h>
#include<iostream>
#include<string.h>
#include <stdlib.h>
#include<math.h>
#include<algorithm>
using namespace std;
const int N = ;
const double pi = atan(1.0)*;
const double eps = 1e-;
struct Circle{
double x,y,r;
}c[N];
typedef Circle Point;
double dis(Point a, Point b){
return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
}
///两圆相交面积模板
double Two_Circle_Area(Circle a,Circle b){
double d = dis(a,b);
if(a.r+b.r<d){ ///相离
return ;
}
if(fabs(a.r-b.r)>=d){ ///内含
double r = min(a.r,b.r);
return pi*r*r;
}
double angleA = acos((a.r*a.r+d*d-b.r*b.r)//a.r/d);
double angleB = acos((b.r*b.r+d*d-a.r*a.r)//b.r/d);
double area1 = a.r*a.r*angleA;
double area2 = b.r*b.r*angleB;
return area1+area2-a.r*d*sin(angleA);
}
int n;
double binary(double l,double r,Circle circle){
double mid;
while((r-l)>=eps){
mid = (l+r)/;
circle.r = mid;
bool flag = false;
for(int i=;i<n;i++){
double area = pi*c[i].r*c[i].r;
if(area/>Two_Circle_Area(circle,c[i])){
flag = true;
break;
}
}
if(flag) l =mid;
else r = mid;
}
return mid;
}
int main(){
int tcase;
scanf("%d",&tcase);
while(tcase--){
scanf("%d",&n);
for(int i=;i<n;i++){
scanf("%lf%lf%lf",&c[i].x,&c[i].y,&c[i].r);
}
Circle circle;
double mi = ;
for(int i=;i<n;i++){
circle.x = c[i].x;
circle.y = c[i].y;
double l=,r = ;
mi = min(mi,binary(l,r,circle));
}
printf("%.4lf\n",mi);
}
return ;
}
hdu 3264(枚举+二分+圆的公共面积)的更多相关文章
- hdu 5120 (求两圆相交的面积
题意:告诉你两个圆环,求圆环相交的面积. /* gyt Live up to every day */ #include<cstdio> #include<cmath> #in ...
- 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 Open-air shopping malls (计算几何-圆相交面积)
传送门:http://acm.hdu.edu.cn/showproblem.php?pid=3264 题意:给你n个圆,坐标和半径,然后要在这n个圆的圆心画一个大圆,大圆与这n个圆相交的面积必须大于等 ...
- 简单几何(圆与多边形公共面积) UVALive 7072 Signal Interference (14广州D)
题目传送门 题意:一个多边形,A点和B点,满足PB <= k * PA的P的范围与多边形的公共面积. 分析:这是个阿波罗尼斯圆.既然是圆,那么设圆的一般方程:(x + D/2) ^ 2 + (y ...
- bjfu1235 两圆公共面积
给定两个圆,求其覆盖的面积,其实也就是求其公共面积(然后用两圆面积和减去此值即得最后结果). 我一开始是用计算几何的方法做的,结果始终不过.代码如下: /* * Author : ben */ #in ...
- POJ 3831 & HDU 3264 Open-air shopping malls(几何)
题目链接: POJ:id=3831" target="_blank">http://poj.org/problem?id=3831 HDU:http://acm.h ...
- codeforce gym/100495/problem/K—Wolf and sheep 两圆求相交面积 与 gym/100495/problem/E—Simple sequence思路简述
之前几乎没写过什么这种几何的计算题.在众多大佬的博客下终于记起来了当时的公式.嘚赶快补计算几何和概率论的坑了... 这题的要求,在对两圆相交的板子略做修改后,很容易实现.这里直接给出代码.重点的部分有 ...
- POJ 2546 & ZOJ 1597 Circular Area(求两圆相交的面积 模板)
题目链接: POJ:http://poj.org/problem? id=2546 ZOJ:problemId=597" target="_blank">http: ...
- HDU4430 Yukari's Birthday(枚举+二分)
Yukari's Birthday HDU4430 就是枚举+二分: 注意处理怎样判断溢出...(因为题目只要10^12) 先前还以为要用到快速幂和等比数列的快速求和(但肯定会超__int64) 而 ...
随机推荐
- Java-JNA使用心得2
自5月初第一次尝试使用Java封装调用C的dll之后,已经先后经历了3次小项目了. 上月末是最近的一次项目实际,任务来的急时间又少,还好在加班加点后还是完成了任务,并把第二次没有实现的功能给实现了(C ...
- 安装macports
Mac下面除了用dmg.pkg来安装软件外,比较方便的还有用MacPorts来帮助你安装其他应用程序,跟BSD中的ports道理一样.MacPorts就像apt-get.yum一样,可以快速安装些软件 ...
- KVO的底层实现原理?如何取消系统默认的KVO并手动触发?
KVO是基于runtime机制实现的 当某个类的属性对象第一次被观察时,系统就会在运行期动态地创建该类的一个派生类(该类的子类),在这个派生类中重写基类中任何被观察属性的setter 方法.派生类在被 ...
- ehcache + spring 整合以及配置说明 ,附带整合问题 (已解决)
新做的项目,因为流量不大 就是一个征信平台,高峰流量不多,但缓存是必须的,cache到server上就可以,不需要额外的memcache.redis之类的东西. 但是遇到一个大坑,事情是这样的: 通过 ...
- hadoop2.6.4【windows7】构建maven项目 系列2
准备windows版本的hadoop2.6.4 下载windows版本的hadoop2.6.4解压在本地 新建maven项目构建hadoop依赖 <?xml version="1.0& ...
- HttpWebRequest调用WebService后台需要Session信息问题的解决办法
今天在用HttpWebRequest调用后台ASP.NET 的WebService方法时遇到了一个问题,后台的WebService方法里使用到了Session对象中的用户信息,而Session对象中的 ...
- 思梦PHP-阿里大鱼手机验证码
小伙伴是否做PC网站的时候,是否遇到过注册用户需要使用短信验证的功能呢?或者找回密码,以及验证用户的信息等等功能!今天思梦PHP就为大家带来ThinkPHP整合阿里大鱼短信验证的功能! 首先,我们要明 ...
- 【bzoj2565】最长双回文串 Manacher+树状数组
原文地址:http://www.cnblogs.com/GXZlegend/p/6802558.html 题目描述 顺序和逆序读起来完全一样的串叫做回文串.比如acbca是回文串,而abc不是(abc ...
- hdu 1172 猜数字
猜数字 Time Limit: 20000/10000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submi ...
- UVA1316 Supermarket
题目描述 有一个商店有许多批货,每一批货又有N(0<=N<= 10^4104 )个商品,同时每一样商品都有收益 P_iPi ,和过期时间 D_iDi (1<= Pi,DiPi,D ...