Maple trees

Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1847    Accepted Submission(s): 574

Problem Description
There are a lot of trees in HDU. Kiki want to surround all the trees with the minimal required length of the rope . As follow,

To
make this problem more simple, consider all the trees are circles in a
plate. The diameter of all the trees are the same (the diameter of a
tree is 1 unit). Kiki can calculate the minimal length of the rope ,
because it's so easy for this smart girl.
But we don't have a rope to
surround the trees. Instead, we only have some circle rings of
different radius. Now I want to know the minimal required radius of the
circle ring. And I don't want to ask her this problem, because she is
busy preparing for the examination.
As a smart ACMer, can you help me ?
 
Input
The
input contains one or more data sets. At first line of each input data
set is number of trees in this data set n (1 <= n <= 100), it is
followed by n coordinates of the trees. Each coordinate is a pair of
integers, and each integer is in [-1000, 1000], it means the position of
a tree’s center. Each pair is separated by blank.
Zero at line for number of trees terminates the input for your program.
 
Output
Minimal required radius of the circle ring I have to choose. The precision should be 10^-2.
 
Sample Input
2
1 0
-1 0
0
 
Sample Output
1.50
 

题意:求将所有树包括进来的最小圆的半径,最后要加上树本身的半径(树的直径为1).

最小圆覆盖问题:
一.概念引入
最小包围圆问题:对于给定的平面上甩个点所组成的一个集合P,求出P的最小包围圆,即包含P中所有点、半径最小
的那个圆。也就是求出这个最小包围圆的圆心位置和半径。 下面是若干性质。 1.有限点集P的最小包围圆是唯一的。这里约定,若P中只有一个点v,则最小包围圆是退化的,其半径为0,圆心为点v。
2.非退化最小包围圆可以由2个或者3个边界点定义。边界上只有两个点,则必定是直径两端,其它点都在圆内部。
3.点集P中,距离最大的2个点A、B不一定都在边界上,但是必有d≥|AB|。
4.直角三角形或钝角三角形的3个顶点的最小包围圆是以最长边为直径的圆;锐角三角形3个顶点的最小包围圆是三角形
的外接圆。
5.新加入点一定在圆上。
以上资料参考:http://www.cnblogs.com/hxsyl/p/3226562.html
 hdu 2215
///最小圆覆盖问题:
/**一.概念引入
最小包围圆问题:对于给定的平面上甩个点所组成的一个集合P,求出P的最小包围圆,即包含P中所有点、半径最小
的那个圆。也就是求出这个最小包围圆的圆心位置和半径。 下面是若干性质。 1.有限点集P的最小包围圆是唯一的。这里约定,若P中只有一个点v,则最小包围圆是退化的,其半径为0,圆心为点v。
2.非退化最小包围圆可以由2个或者3个边界点定义。边界上只有两个点,则必定是直径两端,其它点都在圆内部。
3.点集P中,距离最大的2个点A、B不一定都在边界上,但是必有d≥|AB|。
4.直角三角形或钝角三角形的3个顶点的最小包围圆是以最长边为直径的圆;锐角三角形3个顶点的最小包围圆是三角形
的外接圆。
5.新加入点一定在圆上。
*/
#include <iostream>
#include <cstdio>
#include <string.h>
#include <math.h>
#include <algorithm>
using namespace std;
const int N = ;
const double eps = 1e-; struct Point{
double x,y;
}p[N]; Point c; ///这是最小圆的圆心
double r; ///这是最小圆半径
int n; double dis(Point a,Point b){
return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
}
/**计算外接圆的圆心*/
Point circumcenter(Point a,Point b,Point c){
Point ret=a;
double a1 = (b.x-a.x),b1=(b.y-a.y),c1 = (a1*a1+b1*b1)/;
double a2 = (c.x-a.x),b2=(c.y-a.y),c2 = (a2*a2+b2*b2)/;
double d=a1*b2-a2*b1;
ret.x+=(c1*b2-c2*b1)/d;
ret.y+=(a1*c2-a2*c1)/d;
return ret; }
void min_cover_circle(){
//random_shuffle(p,p+n); ///模板上面的这个函数是打乱点,这个题不要比要还快15MS
c = p[],r = ;
for(int i=;i<n;i++){ ///i是第一个点
if(dis(p[i],c)-r>eps){
c = p[i],r=;
for(int j=;j<i;j++){ ///j是第二个点
if(dis(p[j],c)-r>eps){
c.x = (p[i].x+p[j].x)/;
c.y = (p[i].y+p[j].y)/;
r = dis(p[j],c);
for(int k=;k<j;k++){ ///k是第三个点
if(dis(p[k],c)-r>eps){
c = circumcenter(p[i],p[j],p[k]);
r = dis(p[i],c);
}
}
}
}
}
}
}
int main()
{
while(scanf("%d",&n)!=EOF&&n){
for(int i=;i<n;i++){
scanf("%lf%lf",&p[i].x,&p[i].y);
}
min_cover_circle();
printf("%.2lf\n",r+0.5);
}
return ;
}

hdu 3932

///最小圆覆盖问题:
/**一.概念引入
最小包围圆问题:对于给定的平面上甩个点所组成的一个集合P,求出P的最小包围圆,即包含P中所有点、半径最小
的那个圆。也就是求出这个最小包围圆的圆心位置和半径。 下面是若干性质。 1.有限点集P的最小包围圆是唯一的。这里约定,若P中只有一个点v,则最小包围圆是退化的,其半径为0,圆心为点v。
2.非退化最小包围圆可以由2个或者3个边界点定义。边界上只有两个点,则必定是直径两端,其它点都在圆内部。
3.点集P中,距离最大的2个点A、B不一定都在边界上,但是必有d≥|AB|。
4.直角三角形或钝角三角形的3个顶点的最小包围圆是以最长边为直径的圆;锐角三角形3个顶点的最小包围圆是三角形
的外接圆。
5.新加入点一定在圆上。
*/
#include <iostream>
#include <cstdio>
#include <string.h>
#include <math.h>
#include <algorithm>
using namespace std;
const int N = ;
const double eps = 1e-; struct Point{
double x,y;
}p[N]; Point c; ///这是最小圆的圆心
double r; ///这是最小圆半径
int n; double dis(Point a,Point b){
return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
}
/**计算外接圆的圆心*/
Point circumcenter(Point a,Point b,Point c){
Point ret=a;
double a1 = (b.x-a.x),b1=(b.y-a.y),c1 = (a1*a1+b1*b1)/;
double a2 = (c.x-a.x),b2=(c.y-a.y),c2 = (a2*a2+b2*b2)/;
double d=a1*b2-a2*b1;
ret.x+=(c1*b2-c2*b1)/d;
ret.y+=(a1*c2-a2*c1)/d;
return ret; }
void min_cover_circle(){
//random_shuffle(p,p+n); ///模板上面的这个函数是打乱点,这个题不要比要还快15MS
c = p[],r = ;
for(int i=;i<n;i++){ ///i是第一个点
if(dis(p[i],c)-r>eps){
c = p[i],r=;
for(int j=;j<i;j++){ ///j是第二个点
if(dis(p[j],c)-r>eps){
c.x = (p[i].x+p[j].x)/;
c.y = (p[i].y+p[j].y)/;
r = dis(p[j],c);
for(int k=;k<j;k++){ ///k是第三个点
if(dis(p[k],c)-r>eps){
c = circumcenter(p[i],p[j],p[k]);
r = dis(p[i],c);
}
}
}
}
}
}
}
int main()
{
int X,Y;
while(scanf("%d%d%d",&X,&Y,&n)!=EOF){
for(int i=;i<n;i++){
scanf("%lf%lf",&p[i].x,&p[i].y);
}
min_cover_circle();
printf("(%.1lf,%.1lf).\n%.1lf\n",c.x,c.y,r);
}
return ;
}

hdu 2215 & hdu 3932(最小覆盖圆)的更多相关文章

  1. Maple trees(最小覆盖圆)

    Maple trees Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total S ...

  2. zoj 1450 Minimal Circle 最小覆盖圆

    题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=450 You are to write a program to fi ...

  3. [hdu-3007]Buried memory 最小覆盖圆

    大致题意: 平面上有n个点,求一个最小的圆覆盖住所有点 最小覆盖圆裸题 学习了一波最小覆盖圆算法 #include<cstdio> #include<iostream> #in ...

  4. HDU - 2222,HDU - 2896,HDU - 3065,ZOJ - 3430 AC自动机求文本串和模式串信息(模板题)

    最近正在学AC自动机,按照惯例需要刷一套kuangbin的AC自动机专题巩固 在网上看过很多模板,感觉kuangbin大神的模板最为简洁,于是就选择了用kuangbin大神的模板. AC自动机其实就是 ...

  5. hdu 1150 Machine Schedule 最小覆盖点集

    题意:x,y两台机器各在一边,分别有模式x0 x1 x2 ... xn, y0 y1 y2 ... ym, 现在对给定K个任务,每个任务可以用xi模式或者yj模式完成,同时变换一次模式需要重新启动一次 ...

  6. 2017多校第6场 HDU 6097 Mindis 计算几何,圆的反演

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6097 题意:有一个圆心在原点的圆,给定圆的半径,给定P.Q两点坐标(PO=QO,P.Q不在圆外),取圆 ...

  7. hdu 1045 Fire Net(最小覆盖点+构图(缩点))

    http://acm.hdu.edu.cn/showproblem.php?pid=1045 Fire Net Time Limit:1000MS     Memory Limit:32768KB   ...

  8. HDU 3467 (求五个圆相交面积) Song of the Siren

    还没开始写题解我就已经内牛满面了,从晚饭搞到现在,WA得我都快哭了呢 题意: 在DotA中,你现在1V5,但是你的英雄有一个半径为r的眩晕技能,已知敌方五个英雄的坐标,问能否将该技能投放到一个合适的位 ...

  9. HDU 1883 Phone Cell (圆覆盖最多点)

    题目链接 题意 : 给你很多点和一个半径r,这个半径为r的圆能覆盖的最多的点是多少. 思路 : 对每个点做半径为 r 的圆, 求交集,交集最多的区域的被覆盖次数就是能覆盖的最多的点.贴两个链接,分析的 ...

随机推荐

  1. 【iOS开发】动态添加子视图 UIView 的正确方法

    很多时候哥比较喜欢用代码添加视图,特别是要同时加很多UIView时,而且跟 xib 比起来代码更容易管理,在多人的项目中代码不容易 conflict. 但小牛哥最近发现很多新人都不太清楚正确的使用方法 ...

  2. MySql动态生成SQL并执行

    场景:由于一些表中设计了一些冗余字段,因此在主表修改了该冗余字段的值得时候,需要动态更新在其他表中冗余字段的值 BEGIN #Routine body goes here... /*SQL语句变量*/ ...

  3. 【SSH】——使用ModelDriven的利与弊

    在以往的web开发中,如果要在表单显示什么内容,我们就需要在Action中提前定义好表单显示的所有属性,以及一系列的get和set方法.如果实体类的属性非常多,那么Action中也要定义相同的属性.在 ...

  4. 玩Vim

    1)我一个脚本中粘贴的都是当年在vim下粘的东西,都是带行号的,我现在想把所有的行号都换成回车键,要怎么办呢? %s/[0-9]/^M/g 注:其中回车在vim的输入方法是ctrl+V,会得到^,此时 ...

  5. Spring之JDBC

    jdbc.properties driverClassName=com.mysql.jdbc.Driver url=jdbc:mysql://localhost:3306/ssi?useUnicode ...

  6. 【bzoj3931】[CQOI2015]网络吞吐量 最短路+最大流

    题目描述 路由是指通过计算机网络把信息从源地址传输到目的地址的活动,也是计算机网络设计中的重点和难点.网络中实现路由转发的硬件设备称为路由器.为了使数据包最快的到达目的地,路由器需要选择最优的路径转发 ...

  7. AngularJS设置文本样式小程序

    做了一个这样的程序通过选择框选择样式,下面的段落样式跟着改变.就是想做这么一个东西. <!DOCTYPE html> <html lang="en"> &l ...

  8. [Leetcode] scramble string 乱串

    Given a string s1, we may represent it as a binary tree by partitioning it to two non-empty substrin ...

  9. axios超时重发

    axios的超时是在response中处理的,所以要在response中添加拦截器: axios.interceptors.response.use(undefined, function axios ...

  10. poj3133 Manhattan Wiring

    Manhattan Wiring Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 2016   Accepted: 1162 ...