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以上每一个圆的面积. 比如例子数据,选左边还是选右 ...
随机推荐
- 『ACM C++』 PTA 天梯赛练习集L1 | 050-51
加油加油,努力刷题 ------------------------------------------------L1-050------------------------------------ ...
- POJ 3528--Ultimate Weapon(三维凸包)
Ultimate Weapon Time Limit: 2000MS Memory Limit: 131072K Total Submissions: 2430 Accepted: 1173 ...
- ubnutu 安装protocol buffer
工作中需要使用protocol buffer,需要编译出protocol buffer的动态链接库,然后在别的makefile中链接它, 我的环境是ubnutu16.04,64bit,使用的proto ...
- idea 引入多项目
1.先导入总包 2.右侧mavenmaven,选择parent的pom.xml 3.右上角“Project Structure”检查SDK
- 如何在tornado中以异步的方式调用同步函数
问题 如何在tornado的coroutine中调用同步阻塞的函数 解决方案 使用python内置标准库的concurrent.futures.ThreadPoolExecutor和tornado.c ...
- nuxt 优化项:禁用js的预加载
这里有个nuxt和vue不同的地方,这个地方很有意思,官方的中文文档说得蜜汁自信 ------------------------------- In production, nuxt.js uses ...
- 5. CSS是什么
CSS概念 CSS,层叠样式表,也叫做风格样式表.通过CSS我们可以为页面添加一个美丽的外观,获得更加良好的用户体验.不过值得我们注意的是和HTML一样,CSS也不是编程语言,它只是提供一种配置文件, ...
- MYSQL小函数大用途之-------FIND_IN_SET
没有前言和解释,直接看怎么用 当前我所知道两种用法: 第一种:和like的作用有点相似,但用这个函数会比like更准确的查到你想要的数据. 前提是当前的字段满足俩个要求: 类型为字符型. 储存格式为- ...
- IE8 如何 不显示 选项 卡,直接在任务显示 各个页面?
IE8 如何 不显示 选项 卡,直接在任务显示 各个页面? 在 工具->Internet 选项(o) ->常规--选项卡-设置->把第一个勾去掉 “启用选项卡浏览(需要重新启动 ...
- ES基础知识与高频考点梳理
知识点梳理目录列表 变量类型 JS的数据类型分类和判断 值类型和引用类型 原型与原型链(继承) 原型和原型链的定义 继承写法 作用域和闭包 执行上下文 this 闭包是什么 异步 同步VS异步 异步和 ...