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. python类学习以及mro--多继承属性查找机制

    版权声明:本文为博主原创文章,未经博主允许不得转载. 还记得什么是新式类和旧式类吗? Python中,一个class继承于object,或其bases class里面任意一个继承于object,这个c ...

  2. lintcode-94-二叉树中的最大路径和

    94-二叉树中的最大路径和 给出一棵二叉树,寻找一条路径使其路径和最大,路径可以在任一节点中开始和结束(路径和为两个节点之间所在路径上的节点权值之和) 样例 给出一棵二叉树: 返回 6 标签 动态规划 ...

  3. PAT 1040 有几个PAT

    https://pintia.cn/problem-sets/994805260223102976/problems/994805282389999616 字符串 APPAPT 中包含了两个单词 PA ...

  4. Windows IRP

    IRP(I/O Request Packet),是由IO manager发起的对device的IO请求. 当用户调用系统API,如createFile类似的函数,其实是会交给IO manager来做相 ...

  5. jquery $.getJSON 注意细节

    服务端: var json = "{\"title\": \"Recent Uploads tagged mountrainier\",\" ...

  6. typescript 贪吃蛇[学习过程中,模仿的一个例子]

    代码实现ts: 1 'use strict' module Main { const FloorType = { space: "space", snack: "body ...

  7. Sublime Text 2.0.2 注册码激活

    直接输入注册码就可以了 ----- BEGIN LICENSE ----- Andrew Weber Single User License EA7E-855605 813A03DD 5E4AD9E6 ...

  8. WIndows 相关知识

    Windows服务 图解WinXP局域网共享设置步骤 Win10如何搭建FTP服务器以实现快速传输文件 强大工具psexec工具用法简介 BIOS和CMOS的区别 系统CLSID简介和小技巧

  9. bzoj 4555 [Tjoi2016&Heoi2016]求和 NTT 第二类斯特林数 等比数列求和优化

    [Tjoi2016&Heoi2016]求和 Time Limit: 40 Sec  Memory Limit: 128 MBSubmit: 679  Solved: 534[Submit][S ...

  10. CSS中background-position使用技巧

    一.background-position:left top; 背景图片的左上角和容器(container)的左上角对齐,超出的部分隐藏.等同于 background-position:0,0;也等同 ...