纯粹是为了改进牛吃草里的两圆交模板= =。

  代码如下:

 #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 ——(二分+圆交)的更多相关文章

  1. hdu 3264 Open-air shopping malls(圆相交面积+二分)

    Open-air shopping malls Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/ ...

  2. HDU 3467 Song of the Siren(圆交)

    Problem Description In the unimaginable popular DotA game, a hero Naga Siren, also known as Slithice ...

  3. HDU - 6167: Missile Interception (二分+圆的交)

    pro:二维平面上,给点N个导弹的初始位置,射出方向,速度.问你是找一点,可以从这一点向任意方向发出拦截导弹,速度未V,最小化最大拦截导弹的时间.  如果要拦截一个导弹,必须在导弹发射之后才可以发射拦 ...

  4. hdu3264Open-air shopping malls(二分)

    链接 枚举伞的圆心,最多只有20个,因为必须与某个现有的圆心重合. 然后再二分半径就可以了. #include <iostream> #include<cstdio> #inc ...

  5. 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 ...

  6. 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 ...

  7. POJ 3831 &amp; HDU 3264 Open-air shopping malls(几何)

    题目链接: POJ:id=3831" target="_blank">http://poj.org/problem?id=3831 HDU:http://acm.h ...

  8. hdu 3264(枚举+二分+圆的公共面积)

    Open-air shopping malls Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/ ...

  9. hdu 3264 圆的交+二分

    Open-air shopping malls Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/ ...

随机推荐

  1. JS-运动基础(一)续

    2.淡入淡出的图片 用变量存储透明度 <title>无标题文档</title> <style> #div1{width:293px; height:220px; b ...

  2. elasticsearch 手动控制分片分布

    elasticsearch可以通过reroute api来手动进行索引分片的分配.  不过要想完全手动,必须先把cluster.routing.allocation.disable_allocatio ...

  3. js List<Map> 将偏平化的数组转为树状结构并排序

    数据格式: [ { "id":"d3e8a9d6-e4c6-4dd8-a94f-07733d3c1b59", "parentId":&quo ...

  4. 编程实现prim算法和Dijkstra算法。

    网址链接:http://blog.csdn.net/anialy/article/details/7603170

  5. vm lxc

    taxonomy, 有4种: 进程虚拟机:1.相同指令集(wine),2.不同指令集(java)系统虚拟机:3.相同指令集(kvm),4.不同指令集(qemu) 第4种又可分为直接运行于硬件之上(xe ...

  6. 实例:SSh结合Easyui实现Datagrid的分页显示

    近日学习Easyui,发现非常好用,界面很美观.将学习的心得在此写下,这篇博客写SSh结合Easyui实现Datagrid的分页显示,其他的例如添加.修改.删除.批量删除等功能将在后面的博客一一写来. ...

  7. JAVA字符串编码转换常用类

    无论是对程序的本地化还是国际化,都会涉及到字符编码的转换的问题.尤其在web应用中常常需要处理中文字符,这时就需要进行字符串的编码转换,将字符串编码转换为GBK或者GB2312.一.关键技术点:    ...

  8. 同花顺核新下单程序的"界面不操作超时时间"的设定

    "界面不操作超时时间"的设定 同花顺核新下单程序的'界面不操作超时时间'的设定 系统> 系统设置> 界面设置> 界面不操作超时时间(分): 在这个输入框里填上个3 ...

  9. HDU 4557 非诚勿扰 队列、(记一次失败的SBT尝试)

    非诚勿扰 Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others) [Problem De ...

  10. Ubuntu安装pycharm

    在安装pycharm之前,想看一下需要安装那些软件. 在安装前先下载软件 JDK http://www.oracle.com/technetwork/java/javase/downloads/jdk ...