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以上每一个圆的面积. 比如例子数据,选左边还是选右 ...
随机推荐
- 个人免签即时到账收款接口 bufpay.com 支持多账号收款
有很多 bufpay 的用户反馈,单个手机收款有些时候不太方便,切换手机太麻烦:或者是营业额比较多,希望分摊到多个账号上面. 基于以上的问题,bufpay 开发了多手机收款的功能:每个收款的手机安装 ...
- 安装psutil时提示缺少python.h头文件(作记录)
通过pip或者源码安装psutil,都会提示缺少python.h头文件,错误提示如下: ... psutil/_psutil_common.c:9:20: fatal error: Python.h: ...
- js如何生成id随机数
有时候在我们在新增数据时,需要自动生成主键id等,就经常会遇到需要生成随机数的方法. 下面先介绍一种比较简单的生成随机数方法: //产生随机数函数 function RndNum(n){ var rn ...
- mongodb C++ Driver安装
前言 mongocxx官网地址 http://mongocxx.org/?jmp=docs 本文的安装版本是:mongocxx-r3.2.0.tar.gz . 参考文档安装过程http://mongo ...
- Windows 聚焦(锁屏背景)不更新的解决方法
在 Windows Store 搜索 Dynamic theme 安装后可对桌面背景.锁屏界面等进行设置,非常好用!
- Python学习笔记四:列表,购物车程序实例
列表 切片 中括号,逗号分隔,可以一次取出多个元素,起始位置包括,结束位置不包括(顾头不顾尾) 如果取最后一个,而且不知道列表长度,可以使用负数(-1是最后一个,以此类推) 如果取最后几个,记住从左往 ...
- 令人懊恼的阉割版fabric sdk功能缺失
按理说,fabric本身都是用golang开发的,那么fabric-sdk-go作为其亲儿子,功能应该是最为完善的.然而,与我们想法相左的是,golang版本的sdk反而是最不完备的,开发进度滞后,功 ...
- ARP级ping命令:arping
一.工作原理 地址解析协议,即ARP(Address Resolution Protocol),是根据IP地址获取物理地址的一个TCP/IP协议,是网络链路层的协议,在局域网中使用.主机发送信息时将包 ...
- Bioinfomatics dataset
##Genomic sequence variation ###1000 Genomes Projecthttp://www.1000genomes.org/Data collection and a ...
- JetBrains Makes its Products Free for Students(JetBrains 对学生免费了)
只要你有大学有些 后缀是 .edu的 如:@buaa.edu.cn,用你的邮箱注册,就可以免费试用 JetBrains了 下面是详细注册步骤: Hello everyone, If you’re o ...