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以上每一个圆的面积. 比如例子数据,选左边还是选右 ...
随机推荐
- js内部事件机制--单线程原理
原文地址:https://www.xingkongbj.com/blog/js/event-loop.html http://www.haorooms.com/post/js_xiancheng ht ...
- 笔记: 对称加密算法的PKCS5 和 PKCS7 填充
PKCS #7 填充字符串由一个字节序列组成,每个字节填充该填充字节序列的长度. 假设,块的长度是 8, 数据长度是 5 数据:AA AA AA AA AA PKCS#7 填充 AA AA AA AA ...
- IIS网站的应用程序与虚拟目录的区别及应用
IIS网站 一个网站可以新建无数个应用程序和目录 应用程序 同一域名下程序的独立开发,独立部署的最佳应用策略. 应用程序的应用场景: 1. 域名的分布 比如:www.baidu.com,对于后台,我们 ...
- 05.odoo12开源框架学习
博客为日常工作学习积累总结: 1.odoo12学习 参考博客:https://alanhou.org/centos-odoo-12/ CentOS 7快速安装配置 Odoo 12 添加新用户必做,不然 ...
- centos7中nginx的搭建
./nginx 启动服务./nginx -s stop 关闭服务./nginx -s reload 重新加载配置文件 首先我们应当安装一个依赖的软件包: yum install gcc-c++yum ...
- Kibana6.3.1安装
Kibana安装 Kibana官方下载地址: https://www.elastic.co/cn/downloads/kibana 也可以直接使用以下命令下载(文章下载目录一概为/home/tools ...
- hadoop 部署配置
配置hadoop: 第一个:hadoop-env.sh export JAVA_HOME=/usr/java/jdk1.7.0_65 选择修改日志文件目录(默认目录内日志文件太多易混): export ...
- requests+mongodb爬取今日头条,多进程
import json import os from urllib.parse import urlencode import pymongo import requests from bs4 imp ...
- kubernetes资源清单定义
apiVersion: v1 #必选,版本号,例如v1,版本号必须可以用 kubectl api-versions 查询到 . kind: Pod #必选,Pod metadata: #必选,元数据 ...
- 谁能笑到最后,约瑟夫环-Josephus问题求解
一. 简述Josephus问题 N个人站成一环,从1号开始,用刀将环中后面一个人“消灭“”掉,之后再将刀递给下一个人,这样依次处理,最后留下一个幸存者. 二. 求解方法 1. 约瑟夫问题如果使用 ...