HDU 3264 Open-air shopping malls ——(二分+圆交)
纯粹是为了改进牛吃草里的两圆交模板= =。
代码如下:
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <vector>
#include <math.h>
using namespace std;
const int N = + ;
typedef long long ll;
const double eps = 1e-;
const double pi = acos(-1.0);
double inf = ; struct circle
{
double x,y,r;
void read()
{
scanf("%lf%lf%lf",&x,&y,&r);
}
double calS()
{
return pi*r*r;
}
}c[]; double myabs(double x) {return x < ? -x : x;} double get(circle c1,circle c2)
{
double a = c1.x, b = c1.y, R = c1.r;
double x = c2.x, y = c2.y, r = c2.r;
double dx = myabs(a-x), dy = myabs(b-y);
double d = sqrt(dx*dx+dy*dy);
if(d > R + r) return 0.0;
if(R < r) swap(R,r);
if(d < R-r) return pi*r*r;
double A = 2.0*acos((R*R+d*d-r*r)/(2.0*R*d));
double B = 2.0*acos((r*r+d*d-R*R)/(2.0*r*d));
double s1 = 0.5*A*R*R + 0.5*B*r*r;
double s2 = 0.5*R*R*sin(A) + 0.5*r*r*sin(B);
return s1 - s2;
} int n;
bool solve(circle now)
{
for(int i=;i<=n;i++)
{
if(get(now,c[i]) >= 0.5*c[i].calS()) ;
else return ;
}
return ;
} int main()
{
int T;
scanf("%d",&T);
while(T--)
{
scanf("%d",&n);
for(int i=;i<=n;i++) c[i].read();
double ans = inf;
for(int i=;i<=n;i++)
{
circle now = c[i];
double L = , R = inf;
int CNT = ;
while(CNT--)
{
double mid = (L + R) / ;
now.r = mid;
if(solve(now)) R = mid;
else L = mid;
}
ans = min(ans, R);
}
printf("%.4f\n",ans);
}
return ;
}
HDU 3264 Open-air shopping malls ——(二分+圆交)的更多相关文章
- hdu 3264 Open-air shopping malls(圆相交面积+二分)
Open-air shopping malls Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/ ...
- HDU 3467 Song of the Siren(圆交)
Problem Description In the unimaginable popular DotA game, a hero Naga Siren, also known as Slithice ...
- HDU - 6167: Missile Interception (二分+圆的交)
pro:二维平面上,给点N个导弹的初始位置,射出方向,速度.问你是找一点,可以从这一点向任意方向发出拦截导弹,速度未V,最小化最大拦截导弹的时间. 如果要拦截一个导弹,必须在导弹发射之后才可以发射拦 ...
- hdu3264Open-air shopping malls(二分)
链接 枚举伞的圆心,最多只有20个,因为必须与某个现有的圆心重合. 然后再二分半径就可以了. #include <iostream> #include<cstdio> #inc ...
- 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 ...
- POJ 3831 & HDU 3264 Open-air shopping malls(几何)
题目链接: POJ:id=3831" target="_blank">http://poj.org/problem?id=3831 HDU:http://acm.h ...
- hdu 3264(枚举+二分+圆的公共面积)
Open-air shopping malls Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/ ...
- hdu 3264 圆的交+二分
Open-air shopping malls Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/ ...
随机推荐
- CentOS6下配置Django+Apache+mod_wsgi+Sqlite3过程
0. 安装环境: CentOs版本: VMWare中CentOs 6.4 Apache版本: Httpd 2.2.15 http://httpd.apache.org/ Sqlit ...
- Listview源码分析(1)
首先Listview继承关系: ListView --extends--> AbsListview --extends--> AdapterView --extends--> ...
- reflow和repaint区别?
作者:zccst 重绘和重排之前也知道,但也没有可以详细了解他们的机制,区别,以及对性能的影响. A repaint occurs when changes are made to an elemen ...
- spring,hibernate配置事务 beans.xml
beans.xml <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="htt ...
- angular 实现modal windows效果(即模态窗口,半透明的遮罩层),以及bootstrap(css,components,js)的初步学习
废话不说,直接上代码.可直接看效果,对着分析..今天算是bootstrap 入门了,开心.. 突然居然很多事情就是那样,不要太多的畏惧,迈出第一步其实就成功了一半了. <html ng-app= ...
- createSQLQuery的addEntity跟setResultTransformer方法
createSQLQuery的addEntity和setResultTransformer方法 1. 使用SQLQuery对原生SQL查询执行的控制是通过SQLQuery接口进行的,通过执行Sessi ...
- 2016青岛网络赛 Barricade
Barricade Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Proble ...
- VHD容量调整的方法(保存原有vhd)
VHD容量调整的方法(保存原有vhd)特别对于RAMOS的VHD,调整VHD容量的办法:1.在WIN7或者7PE中,右击我的电脑→管理→磁盘管理,挂载原始VHD文件,然后新建一个VHD文件,初始化,格 ...
- 怎样把人物处理的清晰PS教程
首先打开PS软件,导入一张人物图片 然后复制图层,点滤镜---杂色----减少杂色 点高级 点确定. 点图像-----调整-----匹配颜色在点一下中和,中和看图效果,也可点 也可不点 切记,然后确定 ...
- Allegro pcb -等长设计
1.首先注意打开的Allegro PCB是哪个产品控件,如下图,若打开的是Allegro PCB Designer,在后面,看别人的讲解过程中会找不到“SiXplorer”,原因 就是出在这里,All ...