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个圆相交的面积必须大于等 ...
随机推荐
- Oracle绑定变量
select * from table where id = ? 类似于上面这样的sql,如果不用绑定变量,每次执行时Oracle会认为是不同的sql,会在每次执行时生成一遍执行计划,而执行计划的生成 ...
- CSS select样式列表-------美化列表
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- PHP中cookie和Session
Cookie与Session cookie 列子 if(!isset($_COOKIE['cookie'])){ setcookie("cookie",date('Y-m-d H: ...
- 算法心得1:由$nlogn$复杂度的LIS算法引起的思考
LIS(Longest Increasing Subsequence)是一类典型的动态规划类问题,简化描述如下: 给定$N(n) = \{1,2...,n\}$的一个排列$P(n)$,求$P(n)$中 ...
- Python学习笔记-Day3-python内置函数
python内置函数 1.abs 求绝对值 2.all 判断迭代器中的所有数据是否都为true 如果可迭代的数据的所有数据都为true或可迭代的数据为空,返回True.否则返回False 3.a ...
- 安装python-devel 在升级到python2.7之后
分别执行如下命令: # yum update # yum install centos-release-SCL # yum search all python27 在搜索出的列表中发现python27 ...
- bzoj 2818: Gcd GCD(a,b) = 素数
2818: Gcd Time Limit: 10 Sec Memory Limit: 256 MBSubmit: 1566 Solved: 691[Submit][Status] Descript ...
- ContentProvider官方教程(2)简介、Content URIs
In this document Overview Accessing a provider Content URIs Content Provider Basics A content provid ...
- js css 构建滚动边框
注:预览效果请点击result选项卡,个人认为这种效果非常适合做友情链接. 完整代码 <!DOCTYPE html> <html xmlns="http://www.w3. ...
- 使用MSCOMM发送任意文件,还有一些注意事项
第一步:发送文件 FILE* pSENDFILE = _wfopen(m_edit_chosefile, _T("rb"));//以二进制打开待发送文件的的文件指针 fseek(p ...