题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3007

Each person had do something foolish along with his or her growth.But,when he or she did this that time,they could not predict that this thing is a mistake and they will want this thing would rather not happened.
The world king Sconbin is not the exception.One day,Sconbin was
sleeping,then swakened by one nightmare.It turned out that his love letters to
Dufein were made public in his dream.These foolish letters might ruin his
throne.Sconbin decided to destroy the letters by the military exercises's
opportunity.The missile is the best weapon.Considered the execution of the
missile,Sconbin chose to use one missile with the minimum
destruction.
Sconbin had writen N letters to Dufein, she buried these letters
on different places.Sconbin got the places by difficult,he wants to know where
is the best place launch the missile,and the smallest radius of the burst area.
Let's help Sconbin to get the award.
题意描述:给出n封信的二维坐标,找到一个坐标点,使其距离n封信的最远距离最近。
算法分析:最远点对的模板题。需要注意一点:题目中的坐标点没规律,最远点对的算法针对凸边形,所以首先我们得对题目点集凸包化。
 #include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<vector>
#define inf 0x7fffffff
#define exp 1e-10
#define PI 3.141592654
using namespace std;
const int maxn=+; int n;
struct Point
{
double x,y;
Point(double x=,double y=):x(x),y(y){}
}an[maxn],bn[maxn];
typedef Point Vector;
double dcmp(double x)
{
if (fabs(x)<exp) return ;
return x< ? - : ;
}
Vector operator + (Vector A,Vector B) {return Vector(A.x+B.x , A.y+B.y); }
Vector operator - (Vector A,Vector B) {return Vector(A.x-B.x , A.y-B.y); }
Vector operator * (Vector A,double p) {return Vector(A.x*p , A.y*p); }
Vector operator / (Vector A,double p) {return Vector(A.x/p , A.y/p); }
bool operator < (Point a,Point b) {return a.x<b.x || (a.x==b.x && a.y<b.y); }
bool operator == (Point a,Point b) {return dcmp(a.x-b.x)== && dcmp(a.y-b.y)==; } double Dot(Vector A,Vector B) {return A.x*B.x + A.y*B.y ; }
double Length(Vector A,Vector B) {return sqrt(Dot(A,A)); }
double cross(Vector A,Vector B) {return A.x*B.y - B.x*A.y; } double dist(Point A,Point B)
{
double xx=(A.x-B.x)*(A.x-B.x);
double yy=(A.y-B.y)*(A.y-B.y);
return sqrt(xx+yy);
} Point cur;
double rotating_calipers(Point *ch,int n)
{
int q=;
double ans=-;
cur.x=cur.y=;
ch[n]=ch[];
for (int p= ;p<n ;p++)
{
while (cross(ch[q+]-ch[p+],ch[p]-ch[p+])>cross(ch[q]-ch[p+],ch[p]-ch[p+]))
q=(q+)%n;
double len=dist(ch[p],ch[q]);
double len2=dist(ch[p+],ch[q+]);
if (len>ans+exp)
{
ans=len;
cur.x=(ch[p].x+ch[q].x)/2.0;
cur.y=(ch[p].y+ch[q].y)/2.0;
}
if (len2>ans+exp)
{
ans=len2;
cur.x=(ch[p+].x+ch[q+].x)/2.0;
cur.y=(ch[p+].y+ch[q+].y)/2.0;
}
}
return ans;
} int Convexhull(Point *p,int n,Point *ch)
{
sort(p,p+n);
int m=;
for (int i= ;i<n ;i++)
{
while (m> && dcmp(cross(ch[m-]-ch[m-],p[i]-ch[m-]))<) m--;
ch[m++]=p[i];
}
int k=m;
for (int i=n- ;i>= ;i--)
{
while (m>k && dcmp(cross(ch[m-]-ch[m-],p[i]-ch[m-]))<) m--;
ch[m++]=p[i];
}
if (n>) m--;
return m;
} int main()
{
while (scanf("%d",&n)!=EOF && n)
{
for (int i= ;i<n ;i++) scanf("%lf%lf",&an[i].x,&an[i].y);
if (n==) {printf("%.2lf %.2lf 0.00\n",an[].x,an[].y);continue; }
if (n==) {printf("%.2lf %.2lf %.2lf\n",(an[].x+an[].x)/2.0,
(an[].y+an[].y)/2.0,dist(an[],an[])/2.0);continue; }
int m=Convexhull(an,n,bn);
double ans=rotating_calipers(bn,m);
printf("%.2lf %.2lf %.2lf\n",cur.x,cur.y,ans/2.0);
}
return ;
}

hdu 3007 Buried memory 最远点对的更多相关文章

  1. HDU 3007 Buried memory(计算几何の最小圆覆盖,模版题)

    Problem Description Each person had do something foolish along with his or her growth.But,when he or ...

  2. HDU 3007 Buried memory & ZOJ 1450 Minimal Circle

    题意:给出n个点,求最小包围圆. 解法:这两天一直在学这个神奇的随机增量算法……看了这个http://soft.cs.tsinghua.edu.cn/blog/?q=node/1066之后自己写了好久 ...

  3. HDU - 3007 Buried memory

    传送门 最小圆覆盖模板. //Achen #include<algorithm> #include<iostream> #include<cstring> #inc ...

  4. 【HDOJ】3007 Buried memory

    1. 题目描述有n个点,求能覆盖这n个点的半径最小的圆的圆心及半径. 2. 基本思路算法模板http://soft.cs.tsinghua.edu.cn/blog/?q=node/1066定义Di表示 ...

  5. HDU 3007 模拟退火算法

    Buried memory Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Tot ...

  6. hdu 4666:Hyperspace(最远曼哈顿距离 + STL使用)

    Hyperspace Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)Tota ...

  7. HDU 4666 Hyperspace (最远曼哈顿距离)

    Hyperspace Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)Tota ...

  8. 2018 Multi-University Training Contest 10 CSGO(HDU - 6435)(最远曼哈顿距离)

    有 n 种主武器,m 种副武器.每种武器有一个基础分数k种属性值 X[i] . 选出一种主武器 mw 和一种副武器 sw,使得两种武器的分数和 + 每个属性的差值尽量大.(参考下面的式子) 多维的最远 ...

  9. 【23.68%】【hdu 2871】Memory Control

    Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission ...

随机推荐

  1. dispatchTouchEvent & onInterceptTouchEvent & onTouchEvent

    http://www.cnblogs.com/jqyp/archive/2012/04/25/2469758.html dispatchTouchEvent       分发 onInterceptT ...

  2. phpMyAdmin安装

    phpMyAdmin是MySql的一个Web操作界面. phpMyAdmin官网貌似被和谐了,经常无法访问.不过我们可以从GitHub下载phpMyAdmin. 然后解压,搭建与普通的PHP网站一样. ...

  3. Like ruby of SBM Crusher zip to dict

    how to use the zip to bulid a dict in python? data = """A dynamic, interpreted, open ...

  4. Ztack学习笔记(4)-系统网络分析

    协调器的组网,终端设备和路由设备发现网络以及加入网络 //第一步:Z-Stack 由 main()函数开始执行,main()函数共做了 2 件事:一是系统初始化,另外一件是开始执行轮转查询式操作系统 ...

  5. DoubanFm之设计模式(一)

    前两版DoubanFm写的太戳,第一版可以忽略,当是熟悉WP手机的一些API.. 第二版用了比较多的依赖注入,熟悉了Messenger,过后越写越大,感觉不对,赶快打住..现在开始好好思考各模块了. ...

  6. ED/EP系列4《圈存指令》

    1. 圈存交易 通过圈存交易,持卡人可将其在银行相应账户上的资金划入电子存折或电子钱包中. 特点: 1)--必须在金融终端上联机进行; 2)--必须提交个人识别码(PIN) 步骤: 1) --终端: ...

  7. C语言中断言ASSERT

    我一直以为assert仅仅是个报错函数,事实上,它居然是个宏,并且作用并非"报错". 在经过对其进行一定了解之后,对其作用及用法有了一定的了解,assert()的用法像是一种&qu ...

  8. Android动画解析--XML

    动画类型 Android的animation由四种类型组成 XML中 alpha 渐变透明度动画效果 scale 渐变尺寸伸缩动画效果 translate 画面转换位置移动动画效果 rotate 画面 ...

  9. Knockout : 实现复杂的web聊天窗体

    公司以前一个同事写的这个聊天的窗体,由于是采用了html拼接的方式,外加处理的时候没有合理的划分职责,导致页面js代码量非常庞大(1500行左右).现在这哥们离职了,苦的是我们剩下的人,不多说,我先去 ...

  10. Charles移动端抓包工具使用

    软件Charle 是一个HTTP代理服务器,HTTP监视器,反转代理服务器.它允许一个开发者查看所有连接互联网的HTTP通信.这些包括request, response现HTTP headers (包 ...