HDU 3264/POJ 3831 Open-air shopping malls(计算几何+二分)(2009 Asia Ningbo Regional)
Description
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
Output
题目大意:给n个互相相离的圆,要求以其中一个圆的圆点为中心,画一个大圆,这个大圆要覆盖这n个圆至少一半的面积,求这个大圆的最小半径。
思路:枚举圆心,二分半径判断是否符合条件即可。
代码(0MS):
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cmath>
using namespace std; const int MAXN = ;
const double PI = * acos(0.0);
const double EPF = 1e-; double x[MAXN], y[MAXN], r[MAXN];
int n, T; double dist(double x1, double y1, double x2, double y2) {
int xx = x1 - x2, yy = y1 - y2;
return sqrt(xx * xx + yy * yy);
} double fusiform(double a, double c, double b) {
double angle = * acos((a * a + b * b - c * c) / ( * a * b));
double s1 = a * a * PI * (angle / ( * PI));
double s2 = a * a * sin(angle) / ;
return s1 - s2;
} bool common(double x1, double y1, double r1, double x2, double y2, double r2) {
double d = dist(x1, y1, x2, y2);
if(d >= r1 + r2) return false;
if(d <= fabs(r1 - r2)) {
if(r1 > r2) return true;
else return (r1 * r1 * >= r2 * r2);
}
double value = fusiform(r1, r2, d) + fusiform(r2, r1, d);
return value * >= r2 * r2 * PI;
} bool check(double ox, double oy, double rr) {
for(int i = ; i <= n; ++i)
if(!common(ox, oy, rr, x[i], y[i], r[i])) return false;
return true;
} double calc(double ox, double oy) {
double l = , r = ;
while(r - l > 1e-) {
double mid = (l + r) / ;
if(check(ox, oy, mid)) r = mid;
else l = mid;
}
return l;
} void solve() {
double ans = 1e100, value;
for(int i = ; i <= n; ++i) {
value = calc(x[i], y[i]);
ans = min(ans, value);
}
printf("%.4f\n", ans);
} int main() {
//cout<<PI<<endl;
scanf("%d", &T);
while(T--) {
scanf("%d", &n);
for(int i = ; i <= n; ++i) scanf("%lf%lf%lf", &x[i], &y[i], &r[i]);
solve();
}
}
HDU 3264/POJ 3831 Open-air shopping malls(计算几何+二分)(2009 Asia Ningbo Regional)的更多相关文章
- HDU 3269 P2P File Sharing System(模拟)(2009 Asia Ningbo Regional Contest)
Problem Description Peer-to-peer(P2P) computing technology has been widely used on the Internet to e ...
- 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 3265/POJ 3832 Posters(扫描线+线段树)(2009 Asia Ningbo Regional)
Description Ted has a new house with a huge window. In this big summer, Ted decides to decorate the ...
- HDU 3260/POJ 3827 Facer is learning to swim(DP+搜索)(2009 Asia Ningbo Regional)
Description Facer is addicted to a game called "Tidy is learning to swim". But he finds it ...
- HDU 3262/POJ 3829 Seat taking up is tough(模拟+搜索)(2009 Asia Ningbo Regional)
Description Students often have problems taking up seats. When two students want the same seat, a qu ...
- HDU 3268/POJ 3835 Columbus’s bargain(最短路径+暴力枚举)(2009 Asia Ningbo Regional)
Description On the evening of 3 August 1492, Christopher Columbus departed from Palos de la Frontera ...
- Open-air shopping malls(二分半径,两元交面积)
http://acm.hdu.edu.cn/showproblem.php?pid=3264 Open-air shopping malls Time Limit: 2000/1000 MS (Jav ...
- HDU 3264 Open-air shopping malls ——(二分+圆交)
纯粹是为了改进牛吃草里的两圆交模板= =. 代码如下: #include <stdio.h> #include <algorithm> #include <string. ...
- [hdu 3264] Open-air shopping malls(二分+两圆相交面积)
题目大意是:先给你一些圆,你可以任选这些圆中的一个圆点作圆,这个圆的要求是:你画完以后.这个圆要可以覆盖之前给出的每一个圆一半以上的面积,即覆盖1/2以上每一个圆的面积. 比如例子数据,选左边还是选右 ...
随机推荐
- hashMap 和 linkedHashMap 的区别和联系
直接举例说明. 运行如下例子程序 mport java.util.HashMap; import java.util.Iterator; import java.util.LinkedHashMap; ...
- JavaScript小练习3-用循环使三个DIV变色
题目 初始为黑色,点击后为红色,再次点击为黑色,以后每次点击一次变色. 分析 简单的onclick使用. button的居中可以在外套一个p元素,body中让p居中即可. 三个DIV块的居中,使用ma ...
- Docker镜像浅谈
先抛出几个我在学习过程中产生的几个问题. 1. 容器镜像是什么, 和装系统时的镜像有什么关系? 2. 容器镜像的作用是什么? 3. 不同版本的ubuntu镜像有什么区别, 比如说 ubuntu:18. ...
- eclipse官方下载地址
下载地址: https://www.eclipse.org/downloads/packages/release/Luna/SR2 选择不同版本
- Linux 只显示目录或者文件方法
ls 参数 -a 表示显示所有文件,包含隐藏文件-d 表示显示目录自身的属性,而不是目录中的内容-F 选项会在显示目录条目时,在目录后加一个/ 只显示目录 方法一: find . -type d -m ...
- XSS攻击 && CSRF攻击 基础理解
一个网站,不管多么的帅气,多么的风骚,如果你不安全,那始终都是一个弟弟啊~ 今天又看了下XSS和CSRF攻击的文章,我也想发点什么普及下大家的安全意识,毕竟作为一名拥有伟大梦想的程序员,基本的安全意识 ...
- vue vue-router 完美实现前进刷新,后退不刷新。附scrollBehavior源码解析
需求:在一个vue的项目中,我们需要从一个列表页面点击列表中的某一个详情页面,从详情页面返回不刷新列表,而从列表的上一个页面重新进入列表页面则需要刷新列表. 而浏览器的机制则是每一次的页面打开都会重新 ...
- 配置一个nginx反向代理&负载均衡服务器
一.基本信息 系统(L):CentOS 6.9 #下载地址:http://mirrors.sohu.com 反代&负载均衡(N):NGINX 1.14.0 #下载地址:http://nginx ...
- c语言:矩阵相乘-矩阵相加 新手练习1
#include<stdio.h> #include<stdlib.h> #include<time.h> #include<string.h> voi ...
- 推荐 的FPGA设计经验(3) 物理实现和时间闭环优化
Optimizing Physical Implementation and Timing Closure Planning Physical Implementation When planning ...