hdu 3264(枚举+二分+圆的公共面积)
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
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.
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.
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.
2
0 0 1
2 0 1
#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(枚举+二分+圆的公共面积)的更多相关文章
- hdu 5120 (求两圆相交的面积
题意:告诉你两个圆环,求圆环相交的面积. /* gyt Live up to every day */ #include<cstdio> #include<cmath> #in ...
- hdu 3264 Open-air shopping malls(圆相交面积+二分)
Open-air shopping malls Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/ ...
- HDU 3264 Open-air shopping malls (计算几何-圆相交面积)
传送门:http://acm.hdu.edu.cn/showproblem.php?pid=3264 题意:给你n个圆,坐标和半径,然后要在这n个圆的圆心画一个大圆,大圆与这n个圆相交的面积必须大于等 ...
- 简单几何(圆与多边形公共面积) UVALive 7072 Signal Interference (14广州D)
题目传送门 题意:一个多边形,A点和B点,满足PB <= k * PA的P的范围与多边形的公共面积. 分析:这是个阿波罗尼斯圆.既然是圆,那么设圆的一般方程:(x + D/2) ^ 2 + (y ...
- bjfu1235 两圆公共面积
给定两个圆,求其覆盖的面积,其实也就是求其公共面积(然后用两圆面积和减去此值即得最后结果). 我一开始是用计算几何的方法做的,结果始终不过.代码如下: /* * Author : ben */ #in ...
- POJ 3831 & HDU 3264 Open-air shopping malls(几何)
题目链接: POJ:id=3831" target="_blank">http://poj.org/problem?id=3831 HDU:http://acm.h ...
- codeforce gym/100495/problem/K—Wolf and sheep 两圆求相交面积 与 gym/100495/problem/E—Simple sequence思路简述
之前几乎没写过什么这种几何的计算题.在众多大佬的博客下终于记起来了当时的公式.嘚赶快补计算几何和概率论的坑了... 这题的要求,在对两圆相交的板子略做修改后,很容易实现.这里直接给出代码.重点的部分有 ...
- POJ 2546 & ZOJ 1597 Circular Area(求两圆相交的面积 模板)
题目链接: POJ:http://poj.org/problem? id=2546 ZOJ:problemId=597" target="_blank">http: ...
- HDU4430 Yukari's Birthday(枚举+二分)
Yukari's Birthday HDU4430 就是枚举+二分: 注意处理怎样判断溢出...(因为题目只要10^12) 先前还以为要用到快速幂和等比数列的快速求和(但肯定会超__int64) 而 ...
随机推荐
- Android log 引发的血案
今天调试代码,我打印了一个东西: Log.d("WelcomeActivity", res.str); 结果总是代码执行不到这一行的下一行,程序也没有挂掉.后来,我自己去想各种可能 ...
- 解决不了bug的时候看一下:
解决不了bug的时候看一下: 1.机器是不会出错的,出错的一定是人.只是你还没有意识到哪里出了错. 2.产生bug 的原因想错了,你以为是系统的bug ,那么你肯定就不想着去解决,你也就解决不了. 这 ...
- vue-cli 引入axios
写文章注册登录 首页 下载App × vue-cli 引入axios及跨域使用 星球小霸王 关注 2017.10.04 16:40* 字数 504 阅读 13038评论 2喜欢 18 使用 c ...
- centos7.3配置guacamole
目录 1 安装guacamole所需要的依赖库 2 安装配置tomcat,架设服务 2.1 下载tomcat 2.2 配置环境变量,使tomcat可以找到guacamole客户端配置 2.3 安装gu ...
- python学习笔记十七:base64及md5编码
一.Python Base64编码 Python中进行Base64编码和解码要用base64模块,代码示例: #-*- coding: utf-8 -*- import base64 str = 'c ...
- Abstract Factory 抽象工厂(创建型模式)
1.常规的对象创建方法(以更换QQ空间主题为例) (这里的常规对象指的是由于业务需求,当前实例化的对象有可能被其他相似的对象(有着共同的特性)所取代,例如更换手机铃声:一首歌取代另一首歌(词,曲,和声 ...
- CodeForces-757B Bash's Big Day
题目链接 https://vjudge.net/problem/CodeForces-757B 题目 Description Bash has set out on a journey to beco ...
- oracle存储过程粗解
存储过程创建的语法: create or replace procedure 存储过程名(param1 in type,param2 out type) as 变量1 类型(值范围);变量2 类型(值 ...
- Java性能监控之Instrumentation
注:网上摘取的资料整理出来,供大家学习理解,希望有所帮助. 1.1. Instrumentation 简介 利用 Java 代码,即 java.lang.instrument 做动态 Ins ...
- echarts异步加载
echarts体积很大,在移动端使用异步加载是一种提高渲染速度的方法,结合webpack的做法如下: require.ensure([], function(require){ const echar ...