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. linux压缩和解压缩命令大全--费元星站长

    tar命令 解包:tar zxvf FileName.tar 打包:tar czvf FileName.tar DirName gz命令 解压1:gunzip FileName.gz 解压2:gzip ...

  2. 《Cracking the Coding Interview》——第3章:栈和队列——题目6

    2014-03-19 03:01 题目:给定一个栈,设计一个算法,在只使用栈操作的情况下将其排序.你可以额外用一个栈.排序完成后,最大元素在栈顶. 解法:我在草稿纸上试了试{1,4,2,3}之类的小例 ...

  3. SQL 与关系代数

    Table of Contents 前言 关系与表 关系代数的基本运算 投影 选择 并运算 集合差运算 笛卡尔积 更名运算 关系代数的附加运算 集合交运算 连接运算 自然连接 内连接 外连接 结语 前 ...

  4. 【PTA】Tree Traversals Again

    题目如下: An inorder binary tree traversal can be implemented in a non-recursive way with a stack. For e ...

  5. Thymeleaf 模板 在spring boot 中的引用和应用

    Thymeleaf是一个java类库,他是一个xml/xhtml/html5的模板引擎和Struts框架的freemarker模板类似,可以作为mvc的web应用的view层. Thymeleaf还提 ...

  6. [hdu6435]Problem J. CSGO

    题目大意:给定$n$个$A$类元素和$m$个$B$类元素,每类元素有值$S$和$k$个值$x_0,x_1,\dots,x_{k-1}(k\leqslant 5)$. 要求选出一个$A$类元素$a$和$ ...

  7. 雅礼集训 Day6 T2 Equation 解题报告

    Equation 题目描述 有一棵\(n\)个点的以\(1\)为根的树,以及\(n\)个整数变量\(x_i\).树上\(i\)的父亲是\(f_i\),每条边\((i,f_i)\)有一个权值\(w_i\ ...

  8. 《c程序设计语言》读书笔记-删除字符串中匹配的字符

    #include <stdio.h> #include <string.h> #define Num 10 int main() { int c,i,j = 0,m,n = 0 ...

  9. Avito Cool Challenge 2018:C. Colorful Bricks

    C. Colorful Bricks 题目链接:https://codeforces.com/contest/1081/problem/C 题意: 有n个横向方块,一共有m种颜色,然后有k个方块的颜色 ...

  10. 模拟Json格式传值请求与数据接收

    a.php代码: function http_post_json($url, $jsonStr) { $ch = curl_init(); curl_setopt($ch, CURLOPT_POST, ...