hdu 3264 圆的交+二分
Open-air shopping malls
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1822 Accepted Submission(s): 651
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.
2
0 0 1
2 0 1
题目大意:给n个圆,求以某个圆的圆心为圆心作圆它与所有圆的交都大于等于圆面积一半的最小半径。
思路:枚举圆心二分找答案。
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std; const double eps=1e-;
const double Pi=acos(-1.0);
struct Point
{
double x,y;
Point(double x=,double y=):x(x),y(y) {}
};
typedef Point Vector;
Vector operator +(Vector A,Vector B){return Vector(A.x+B.x,A.y+B.y);}
Vector operator -(Vector A,Vector B){return Vector(A.x-B.x,A.y-B.y);}
Vector operator *(Vector A,double p){return Vector(A.x*p,A.y*p);}
Vector operator /(Vector A,double p){return Vector(A.x/p,A.y/p);}
double Dot(Vector A,Vector B){return A.x*B.x+A.y*B.y;}//点积
double Length(Vector A){return sqrt(Dot(A,A));}//向量的长度
inline double min(double a,double b){return a>b?b:a;}
const int maxn=;
int n;
struct circle
{
Point c;
double r;
}C[maxn]; double getarea(int id,int i,double r)
{
double clen=Length(C[id].c-C[i].c);
if(clen>=r+C[i].r) return ;
double t=min(r,C[i].r);
if(clen<=fabs(r-C[i].r)) return Pi*t*t;
double ang1=acos((r*r+clen*clen-C[i].r*C[i].r)/(*r*clen));
double ang2=acos((C[i].r*C[i].r+clen*clen-r*r)/(*C[i].r*clen));
double area=ang1*r*r+ang2*C[i].r*C[i].r;
area-=sin(ang2)*C[i].r*clen;
return area;
} bool judge(int id,double r)
{
for(int i=;i<n;i++)
{
double area=getarea(id,i,r);
if(Pi*C[i].r*C[i].r>*area)
return false;
}
return true;
} double binary_search(double l,double r,int id)
{
double mid;
while(r-l>eps)
{
mid=(l+r)/2.0;
if(judge(id,mid)) r=mid;
else l=mid;
}
return l;
} void solve()
{
double ans=;
for(int i=;i<n;i++)
ans=min(ans,binary_search(,,i));
printf("%.4lf\n",ans);
}
int main()
{
int i,t;
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
for(i=;i<n;i++)
scanf("%lf%lf%lf",&C[i].c.x,&C[i].c.y,&C[i].r);
solve();
}
return ;
}
hdu 3264 圆的交+二分的更多相关文章
- hdu 3433 A Task Process 二分+dp
A Task Process Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) T ...
- HDU 3511 圆扫描线
找最深的圆,输出层数 类似POJ 2932的做法 圆扫描线即可.这里要记录各个圆的层数,所以多加一个维护编号的就行了. /** @Date : 2017-10-18 18:16:52 * @FileN ...
- hdu 5111 树上求交
hdu 5111 树上求交(树链剖分 + 主席树) 题意: 给出两棵树,大小分别为\(n1\),\(n2\), 树上的结点权值为\(weight_i\) 同一棵树上的结点权值各不相同,不同树上的结点权 ...
- HDU 3622 Bomb Game(二分+2-SAT)
Bomb Game Time Limit: 10000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total ...
- HDU 3264 Open-air shopping malls ——(二分+圆交)
纯粹是为了改进牛吃草里的两圆交模板= =. 代码如下: #include <stdio.h> #include <algorithm> #include <string. ...
- [hdu 3264] Open-air shopping malls(二分+两圆相交面积)
题目大意是:先给你一些圆,你可以任选这些圆中的一个圆点作圆,这个圆的要求是:你画完以后.这个圆要可以覆盖之前给出的每一个圆一半以上的面积,即覆盖1/2以上每一个圆的面积. 比如例子数据,选左边还是选右 ...
- HDU - 6167: Missile Interception (二分+圆的交)
pro:二维平面上,给点N个导弹的初始位置,射出方向,速度.问你是找一点,可以从这一点向任意方向发出拦截导弹,速度未V,最小化最大拦截导弹的时间. 如果要拦截一个导弹,必须在导弹发射之后才可以发射拦 ...
- 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 ...
- hdu 3264(枚举+二分+圆的公共面积)
Open-air shopping malls Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/ ...
随机推荐
- 拨出网线后,网卡IP丢失
/etc/network/interfaces与NetworkManager 问题:在Centos7上把网线拨出后,发现网卡状态是down,并且网卡上的IP丢失 原因:此网卡被NetworkManag ...
- c#中的自定义泛型类、泛型方法和泛型接口
泛型的产生其中一个原因就是为了解决原来集合类中元素的装箱和拆箱问题: 一.泛型类: /// <summary> /// 返回前台的消息 /// </summary> ...
- 协议(Protocol)与委托代理(Delegate)
协议(Protocol)的作用: 1. 规范接口,用来定义一套公用的接口: 2. 约束或筛选对象. 代理(Delegate): 它本身是一种设计模式,委托一个对象<遵守协议>去做某件事情, ...
- JAVA 修改环境变量不重启电脑生效方法
1. 在安装JDK1.6(高版本)时(本机先安装jdk1.6再安装的jdk1.5),自动将java.exe.javaw.exe.javaws.exe三个可执行文件复制到了C:\Windows\Sys ...
- 基于idea创建Tomcat远程调试
编辑完catalina文件后重启tomcat
- JS处理数据四舍五入,tofixed与round的区别
此区别是在做微信端有关绑定设备数据曲线平滑处理的过程中,进行验证时候无意发现. 1 .tofixed方法 toFixed() 方法可把 Number 四舍五入为指定小数位数的数字.例如将数据Num保留 ...
- redis集群监控之Redis-monitor部
为了对以后有可能面临的redis集群监控做准备,这两天在准备这方面的事情,现在将其中的过程记录一下. 首先是“Ronney-Hua”的这篇文章对三中开源监控软件做了对比 文章地址:https://bl ...
- The 2018 ACM-ICPC Chinese Collegiate Programming Contest Take Your Seat
/* 证明过程如下 :第一种情况:按1到n的顺序上飞机,1会随意选一个,剩下的上去时若与自己序号相同的座位空就坐下去,若被占了就也会随意选一个.求最后一个人坐在应坐位置的概率 */ #include ...
- x200 xp 驱动下载
http://support.lenovo.com/en_US/downloads/detail.page?&LegacyDocID=MIGR-70602
- python面试题解析(前端、框架和其他)
答: HTTP是一个属于应用层的面向对象的协议,由于其简捷.快速的方式,适用于分布式超媒体信息系统.它于1990年提出,经过几年的使用与发展,得到不断地完善和扩展.目前在WWW中使用的是HTTP/1. ...