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/ ...
随机推荐
- UVALive 4992 Jungle Outpost(半平面交)
题意:给你n个塔(点)形成一个顺时针的凸包,敌人可以摧毁任何塔,摧毁后剩下的塔再组成凸包 在开始的凸包内选一点为主塔,保证敌人摧毁尽量多塔时主塔都还在现在的凸包内,求出最多摧毁的塔 题解:这题关键就是 ...
- DOM4j 操作XML
<?xml version="1.0" encoding="GBK"?> <persons> <men> <perso ...
- Friends and Subsequences
Friends and Subsequences Mike and !Mike are old childhood rivals, they are opposite in everything th ...
- Android Paint画笔及Color .
引自:http://blog.csdn.net/q445697127/article/details/7736926 Paint paint = new Paint(); // 设置paint为无锯齿 ...
- 新手常见的python报错及解决方案
此篇文章整理新手编写代码常见的一些错误,有些错误是粗心的错误,但对于新手而已,会折腾很长时间才搞定,所以在此总结下我遇到的一些问题.希望帮助到刚入门的朋友们.后续会不断补充. 目录 1.NameErr ...
- Struts2利用注解实现action跳转
使用注解来配置Action的最大好处就是可以实现零配置,但是事务都是有利有弊的,使用方便,维护起来就没那么方便了. 要使用注解方式,我们必须添加一个额外包:struts2-convention-plu ...
- 配置glance使用NFS后端
首先先使用“glance image-delete”命令删除所有镜像,释放磁盘空间. 停止glance服务:service openstack-glance-api stopservice opens ...
- Quartz定时调度
测试类 import static org.quartz.JobBuilder.newJob; import static org.quartz.TriggerBuilder.newTrigger; ...
- 「CSS3 」3D效果 & 透视
CSS3d透视 perspective属性 原文链接:https://segmentfault.com/a/1190000003843764
- ExtJS简介--车辆调度
http://www.cnblogs.com/gaoweipeng/archive/2009/11/11/1599969.html