hdu3264Open-air shopping malls(二分)
枚举伞的圆心,最多只有20个,因为必须与某个现有的圆心重合。
然后再二分半径就可以了。
#include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<stdlib.h>
#include<vector>
#include<cmath>
#include<queue>
#include<set>
using namespace std;
#define N 25
#define LL long long
#define INF 0xfffffff
const double eps = 1e-;
const double pi = acos(-1.0);
const double inf = ~0u>>;
struct point
{
double x,y;
double r,s;
point(double x=,double y=):x(x),y(y) {}
} p[N];
int n;
typedef point pointt;
pointt operator -(point a,point b)
{
return point(a.x-b.x,a.y-b.y);
}
int dcmp(double x)
{
if(fabs(x)<eps) return ;
return x<?-:;
}
double circle_area(point a,point b)
{
double s,d,t,t1;
d=sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
if(d>=a.r+b.r) s=;
else if(d<=fabs(a.r-b.r)) s=min(acos(-1.0)*a.r*a.r,acos(-1.0)*b.r*b.r);
else
{
t=(a.r*a.r+d*d-b.r*b.r)/2.0/d;
t1=sqrt(a.r*a.r-t*t);
s=-d*t1+a.r*a.r*acos(t/a.r)+b.r*b.r*acos((d-t)/b.r);
}
return s;
}
int cal(double mid,point pp)
{
int i;
double sum;
pp.r = mid;
for(i = ; i <= n ; i++)
{
sum = circle_area(pp,p[i]);
if(dcmp(sum-p[i].s/)<) return ;
}
//cout<<mid<<" "<<pp.x<<" "<<pp.y<<" "<<pp.r<<endl;
return ;
}
double solve(point pp)
{
double rig = ,lef = ,mid;
while(rig-lef>eps)
{
mid = (rig+lef)/;
if(cal(mid,pp))
rig = mid;
else lef = mid;
}
return rig;
}
int main()
{
int t,i;
cin>>t;
while(t--)
{
scanf("%d",&n);
for(i = ; i <= n ; i++)
{
scanf("%lf%lf%lf",&p[i].x,&p[i].y,&p[i].r);
p[i].s = pi*p[i].r*p[i].r;
}
double ans = INF;
for(i = ; i <= n ; i++)
{
ans = min(ans,solve(p[i]));
}
printf("%.4f\n",ans);
}
return ;
}
hdu3264Open-air shopping malls(二分)的更多相关文章
- Open-air shopping malls(二分半径,两元交面积)
http://acm.hdu.edu.cn/showproblem.php?pid=3264 Open-air shopping malls Time Limit: 2000/1000 MS (Jav ...
- 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/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 ...
- hdu 3264 Open-air shopping malls(圆相交面积+二分)
Open-air shopping malls Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/ ...
- POJ 3831 & HDU 3264 Open-air shopping malls(几何)
题目链接: POJ:id=3831" target="_blank">http://poj.org/problem?id=3831 HDU:http://acm.h ...
- UVALive - 6572 Shopping Malls floyd
题目链接: http://acm.hust.edu.cn/vjudge/problem/48416 Shopping Malls Time Limit: 3000MS 问题描述 We want to ...
- [hdu 3264] Open-air shopping malls(二分+两圆相交面积)
题目大意是:先给你一些圆,你可以任选这些圆中的一个圆点作圆,这个圆的要求是:你画完以后.这个圆要可以覆盖之前给出的每一个圆一半以上的面积,即覆盖1/2以上每一个圆的面积. 比如例子数据,选左边还是选右 ...
- HDU 3264 Open-air shopping malls ——(二分+圆交)
纯粹是为了改进牛吃草里的两圆交模板= =. 代码如下: #include <stdio.h> #include <algorithm> #include <string. ...
- HDU 3264 Open-air shopping malls (计算几何-圆相交面积)
传送门:http://acm.hdu.edu.cn/showproblem.php?pid=3264 题意:给你n个圆,坐标和半径,然后要在这n个圆的圆心画一个大圆,大圆与这n个圆相交的面积必须大于等 ...
随机推荐
- 深入浅出Windows Phone 8应用开发
刚刚拿到<深入浅出Windows Phone 8应用开发>这本书,开始捣鼓我的Nokia Lumia 925T,已经有开发一个属于自己的App的想法了,计划先不公布了,等我这个App上线了 ...
- JS参数传值
1.JS获取URL参数值 //js获取url参数值 function request(paras) { var url = location.href; , url.length).split(&qu ...
- Ajax的基本语法
//声明XMLHttpRequest var xmlHttp = null; // 创建XMLHttpRequest对象兼容所有浏览器 function createXMLHttpR ...
- [Ogre][地形]OgreTerrain分析以及使用
Ogre 1.7.2中的地形教程 ○读者可以对照着Ogre1.7.2中的terrain.h源码进行阅读加深理解,蓝色部分均为源码 ○去除了一些具体场景比如添加mesh,设置setAmbientLigh ...
- JVM的classloader(转)
Java中一共有四个类加载器,之所以叫类加载器,是程序要用到某个类的时候,要用类加载器载入内存. 这四个类加载器分别为:Bootstrap ClassLoader.Extension Class ...
- 20151224001 GridView 多按钮的各种使用方法
<asp:GridView ID="GridView1" runat="server" AllowPaging=" ...
- Java学习之路(五)
1:补充: 使用super也可以调用父类的成员函数 格式 : super.函数名(); 2:抽象类与抽象函数 抽象函数的定义: 只有函数的定义,没有函数体的函数被称为抽象函数 抽象类的定义: 使用 ...
- 理解mipi协议
完成mipi信号通道分配后,需要生成与物理层对接的时序.同步信号: MIPI规定,传输过程中,包内是200mV.包间以及包启动和包结束时是1.2V,两种不同的电压摆幅,需要两组不同的LVDS驱动电路在 ...
- 2016 Al-Baath University Training Camp Contest-1 B
Description A group of junior programmers are attending an advanced programming camp, where they lea ...
- JAVA线程池的创建
/** * 创建不同类型的线程池 Executors * * @author */ public class ThreadPoolTest01 { public static void main(St ...