Open-air shopping malls

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 2344    Accepted Submission(s): 866

Problem Description
The
city of M is a famous shopping city and its open-air shopping malls are
extremely attractive. During the tourist seasons, thousands of people
crowded into these shopping malls and enjoy the vary-different shopping.

Unfortunately,
the climate has changed little by little and now rainy days seriously
affected the operation of open-air shopping malls—it’s obvious that
nobody will have a good mood when shopping in the rain. In order to
change this situation, the manager of these open-air shopping malls
would like to build a giant umbrella to solve this problem.

These
shopping malls can be considered as different circles. It is guaranteed
that these circles will not intersect with each other and no circles
will be contained in another one. The giant umbrella is also a circle.
Due to some technical reasons, the center of the umbrella must coincide
with the center of a shopping mall. Furthermore, a fine survey shows
that for any mall, covering half of its area is enough for people to
seek shelter from the rain, so the task is to decide the minimum radius
of the giant umbrella so that for every shopping mall, the umbrella can
cover at least half area of the mall.

 
Input
The input consists of multiple test cases.
The first line of the input contains one integer T (1<=T<=10), which is the number of test cases.
For each test case, there is one integer N (1<=N<=20) in the first line, representing the number of shopping malls.
The
following N lines each contain three integers X,Y,R, representing that
the mall has a shape of a circle with radius R and its center is
positioned at (X,Y). X and Y are in the range of [-10000,10000] and R is
a positive integer less than 2000.
 
Output
For
each test case, output one line contains a real number rounded to 4
decimal places, representing the minimum radius of the giant umbrella
that meets the demands.
 
Sample Input
1
2
0 0 1
2 0 1
 
Sample Output
2.0822
题意:平面上有一些圆,现在找一个圆的圆心为圆心做一个大圆出来,然后这个大圆至少要包含每个圆的1/2的面积,求这个大圆的最小半径。
题解:枚举每个点的圆心,二分求解。。WA了好久,竟然是我的圆公共面积的模板有问题,,幸好查出来了,,不然以后做模板的话有问题都不知道错哪里。。
内含的double 习惯性的打成了int
 
#include<stdio.h>
#include<iostream>
#include<string.h>
#include <stdlib.h>
#include<math.h>
#include<algorithm>
using namespace std;
const int N = ;
const double pi = atan(1.0)*;
const double eps = 1e-;
struct Circle{
double x,y,r;
}c[N];
typedef Circle Point;
double dis(Point a, Point b){
return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
}
///两圆相交面积模板
double Two_Circle_Area(Circle a,Circle b){
double d = dis(a,b);
if(a.r+b.r<d){ ///相离
return ;
}
if(fabs(a.r-b.r)>=d){ ///内含
double r = min(a.r,b.r);
return pi*r*r;
}
double angleA = acos((a.r*a.r+d*d-b.r*b.r)//a.r/d);
double angleB = acos((b.r*b.r+d*d-a.r*a.r)//b.r/d);
double area1 = a.r*a.r*angleA;
double area2 = b.r*b.r*angleB;
return area1+area2-a.r*d*sin(angleA);
}
int n;
double binary(double l,double r,Circle circle){
double mid;
while((r-l)>=eps){
mid = (l+r)/;
circle.r = mid;
bool flag = false;
for(int i=;i<n;i++){
double area = pi*c[i].r*c[i].r;
if(area/>Two_Circle_Area(circle,c[i])){
flag = true;
break;
}
}
if(flag) l =mid;
else r = mid;
}
return mid;
}
int main(){
int tcase;
scanf("%d",&tcase);
while(tcase--){
scanf("%d",&n);
for(int i=;i<n;i++){
scanf("%lf%lf%lf",&c[i].x,&c[i].y,&c[i].r);
}
Circle circle;
double mi = ;
for(int i=;i<n;i++){
circle.x = c[i].x;
circle.y = c[i].y;
double l=,r = ;
mi = min(mi,binary(l,r,circle));
}
printf("%.4lf\n",mi);
}
return ;
}

hdu 3264(枚举+二分+圆的公共面积)的更多相关文章

  1. hdu 5120 (求两圆相交的面积

    题意:告诉你两个圆环,求圆环相交的面积. /* gyt Live up to every day */ #include<cstdio> #include<cmath> #in ...

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

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

  3. HDU 3264 Open-air shopping malls (计算几何-圆相交面积)

    传送门:http://acm.hdu.edu.cn/showproblem.php?pid=3264 题意:给你n个圆,坐标和半径,然后要在这n个圆的圆心画一个大圆,大圆与这n个圆相交的面积必须大于等 ...

  4. 简单几何(圆与多边形公共面积) UVALive 7072 Signal Interference (14广州D)

    题目传送门 题意:一个多边形,A点和B点,满足PB <= k * PA的P的范围与多边形的公共面积. 分析:这是个阿波罗尼斯圆.既然是圆,那么设圆的一般方程:(x + D/2) ^ 2 + (y ...

  5. bjfu1235 两圆公共面积

    给定两个圆,求其覆盖的面积,其实也就是求其公共面积(然后用两圆面积和减去此值即得最后结果). 我一开始是用计算几何的方法做的,结果始终不过.代码如下: /* * Author : ben */ #in ...

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

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

  7. codeforce gym/100495/problem/K—Wolf and sheep 两圆求相交面积 与 gym/100495/problem/E—Simple sequence思路简述

    之前几乎没写过什么这种几何的计算题.在众多大佬的博客下终于记起来了当时的公式.嘚赶快补计算几何和概率论的坑了... 这题的要求,在对两圆相交的板子略做修改后,很容易实现.这里直接给出代码.重点的部分有 ...

  8. POJ 2546 &amp; ZOJ 1597 Circular Area(求两圆相交的面积 模板)

    题目链接: POJ:http://poj.org/problem? id=2546 ZOJ:problemId=597" target="_blank">http: ...

  9. HDU4430 Yukari's Birthday(枚举+二分)

    Yukari's Birthday  HDU4430 就是枚举+二分: 注意处理怎样判断溢出...(因为题目只要10^12) 先前还以为要用到快速幂和等比数列的快速求和(但肯定会超__int64) 而 ...

随机推荐

  1. CodeForces 879D Teams Formation

    题意 将一个长度为\(n\)的数组重复\(m\)遍得到一个长度为\(n \times m\)的新序列,然后消掉新序列中连续\(k\)个相同的元素,不断重复这一过程,求最后剩下的序列的长度 分析 首先可 ...

  2. hadoop进阶

    Java 多线程安全机制 1.操作系统有两个容易混淆的概念,进程和线程. 进程:一个计算机程序的运行实例,包含了需要执行的指令:有自己的独立地址空间,包含程序内容和数据:不同进程的地址空间是互相隔离的 ...

  3. JQuery方法总结

    JQuery方法总结 Dom: Attribute:(属性) $("p").addClass(css中定义的样式类型); 给某个元素添加样式 $("img"). ...

  4. Block那些事儿

    1.Block底层原理实现 首先我们来看四个函数 void test1() { int a = 10; void (^block)() = ^{ NSLog(@"a is %d", ...

  5. 关于mac ox node安装报 npm ERR! registry error parsing json

    想安装grunt 遇到2个问题 让npm重新设置一下config: npm config set registry http://registry.cnpmjs.org 然后还报 npm ERR! E ...

  6. 剑指Offer - 九度1522 - 包含min函数的栈

    剑指Offer - 九度1522 - 包含min函数的栈2013-12-01 23:44 题目描述: 定义栈的数据结构,请在该类型中实现一个能够得到栈最小元素的min函数. 输入: 输入可能包含多个测 ...

  7. SSH非交互式密码授权远程执行脚本

    公司有上百台服务器,需要为每台服务器都执行一个脚本,因为所有服务器的账号密码都是一样的,所以可以不用搭建ansible等自动化运维工具,我们直接通过SSH远程执行即可完成. 本文以三台服务器为例,系统 ...

  8. (原)Unreal源码搬山-动画篇 自定义动画节点(一)

    @author:黑袍小道 太忙了,来更新下,嘿嘿 前言: 本文是接着上文 Unreal搬山之动画模块_Unreal动画流程和框架,进行简单入门如何自定义动画图标的AnimNode. 正文: 一.Ani ...

  9. (原、整)BSP的江湖传说

    @author:黑袍小道 查看随缘,当苦无妨,良人可归.     引言 为什么叫江湖传说,因为实现了第一人是卡马克,就这么简单.(不接受那啥) Quake3:http://www.mralligato ...

  10. Gym100286C Clock

    不想打题面,题面戳这里. 被这题吓到了,感觉无从下手.最后还是看着题解和别人的代码加以改编最后写出了的.其实理解之后写出了也就是三四十行的样子了. 首先题目有个很重要的条件--转动某个针只会对周期比他 ...