http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1107

Quoit Design


Time Limit: 5 Seconds      Memory Limit: 32768 KB

Have you ever played quoit in a playground? Quoit is a game in which flat rings are pitched at some toys, with all the toys encircled awarded.
In the field of Cyberground, the position of each toy is fixed, and the ring is carefully designed so it can only encircle one toy at a time. On the other hand, to make the game look more attractive, the ring is designed to have the largest radius. Given a configuration of the field, you are supposed to find the radius of such a ring.

Assume that all the toys are points on a plane. A point is encircled by the ring if the distance between the point and the center of the ring is strictly less than the radius of the ring. If two toys are placed at the same point, the radius of the ring is considered to be 0.

Input

The input consists of several test cases. For each case, the first line contains an integer N (2 <= N <= 100,000), the total number of toys in the field. Then N lines follow, each contains a pair of (x, y) which are the coordinates of a toy. The input is terminated by N = 0.

Output

For each test case, print in one line the radius of the ring required by the Cyberground manager, accurate up to 2 decimal places.

Sample Input

2
0 0
1 1
2
1 1
1 1
3
-1.5 0
0 0
0 1.5
0

Sample Output

0.71
0.00
0.75

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

参考了模板写的,确实不是很懂

来源:http://blog.csdn.net/cxiaokai/article/details/6661005

参考资料:http://blog.csdn.net/lishuhuakai/article/details/9133961

http://blog.csdn.net/hackbuteer1/article/details/7482232

尚待理解

 #include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#define MAXX 100005
using namespace std; struct point
{
double x;
double y;
}p[MAXX],p1[MAXX],p2[MAXX]; bool cmpx(point a,point b)
{
return a.x < b.x;
}
bool cmpy(point a,point b)
{
return a.y < b.y;
}
double dis(point a,point b)
{
return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
}
double minn(double a,double b)
{
return a > b ? b : a;
}
double closest(int l,int r)
{
if(l+ == r)return dis(p1[l],p1[r]);
if(l+ == r)
return minn(dis(p1[l],p1[l+]),minn(dis(p1[l],p1[r]),dis(p1[l+],p1[r])));
int mid=(l+r)>>;
double ans=minn(closest(l,mid),closest(mid+,r));
int cn=;
for(int i=l; i<=r; i++)
{
if(p1[i].x>=p1[mid].x-ans&&p1[i].x<=p1[mid].x+ans)
{
p2[cn++]=p1[i];
}
}
sort(p2,p2+cn,cmpy);
for(int i=; i<cn; i++)
{
for(int j=i+; j<cn; j++)
{
if(p2[j].y-p2[i].y>=ans)
break;
ans=minn(ans,dis(p2[i],p2[j]));
}
}
return ans;
} int main()
{ int n;
while(scanf("%d",&n)!=EOF&&n)
{
for(int i=; i<n; i++)
{
scanf("%lf%lf",&p[i].x,&p[i].y);
p1[i]=p[i];
}
sort(p1,p1+n,cmpx);
double dist=closest(,n-);
printf("%.2lf\n",dist/);
}
return ;
}

zoj 2107&&hdu 1007最近点对问题的更多相关文章

  1. hdu 1007最近点对问题

    先说下题意,很简单,给n个点的坐标,求距离最近的一对点之间距离的一半.第一行是一个数n表示有n个点,接下来n行是n个点的x坐标和y坐标,实数. 这个题目其实就是求最近点对的距离.主要思想就是分治.先把 ...

  2. hdu 1007 最近点对问题(Splay解法)

    为什么要写这个题..经典啊,当然,别以为我用分治做的,不过主要思想还是那神奇的六个点共存(一个h*2h的矩形中最多能放下多少个点使得两两距离不超过h) 其实我是在这里看到的 http://commun ...

  3. HDU 1007 Quoit Design(二分+浮点数精度控制)

    Quoit Design Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) To ...

  4. HDU 1007 Quoit Design(经典最近点对问题)

    传送门: http://acm.hdu.edu.cn/showproblem.php?pid=1007 Quoit Design Time Limit: 10000/5000 MS (Java/Oth ...

  5. HDU 1007 Quoit Design 平面内最近点对

    http://acm.hdu.edu.cn/showproblem.php?pid=1007 上半年在人人上看到过这个题,当时就知道用分治但是没有仔细想... 今年多校又出了这个...于是学习了一下平 ...

  6. HDU 1007:Quoit Design(分治求最近点对)

    http://acm.hdu.edu.cn/showproblem.php?pid=1007 题意:平面上有n个点,问最近的两个点之间的距离的一半是多少. 思路:用分治做.把整体分为左右两个部分,那么 ...

  7. HDU 1007(套圈 最近点对距离)

    题意是求出所给各点中最近点对的距离的一半(背景忽略). 用分治的思想,先根据各点的横坐标进行排序,以中间的点为界,分别求出左边点集的最小距离和右边点集的最小距离,然后开始合并,分别求左右点集中各点与中 ...

  8. hdu 1007 Quoit Design(分治法求最近点对)

    大致题意:给N个点,求最近点对的距离 d :输出:r = d/2. // Time 2093 ms; Memory 1812 K #include<iostream> #include&l ...

  9. HDU 1007 Quoit Design(计算几何の最近点对)

    Problem Description Have you ever played quoit in a playground? Quoit is a game in which flat rings ...

随机推荐

  1. C语言资源

    0.C自带库/函数在线文档 http://www.acm.uiuc.edu/webmonkeys/book/c_guide/ 1.so文件制作和使用 http://blog.csdn.net/love ...

  2. Asp.Net MVC 模型验证详解-实现客户端、服务端双重验证

    概要 在asp.net webform开发中经常会对用户提交输入的信息进行校验,一般为了安全起见大家都会在客户端进行Javascript(利于交互).服务端双重校验(安全).书写校验代码是一个繁琐的过 ...

  3. lamp环境编译(实际通过)

    CentOS:5.5Apache:2.2.9PHP:5.2.6MySQL:5.0.41 条件: yum install gccyum install gcc-c++ vi/etc/yum.repos. ...

  4. 使用Application Loader打包上传AppStore流程

    配置完你的证书,Bundle Identifier 和描述文件的配置 然后配置工程打开你项目工程 第一步,这里不能选择模拟器,选择iOS Device 如果不支持横屏,把这2个勾去掉 然后查看版本号和 ...

  5. docker RESTful API

    https://docs.docker.com/engine/reference/api/docker_remote_api/

  6. seo伪原创技术原理分析,php实现伪原创示例

    seo伪原创技术原理分析,php实现伪原创示例 现在seo伪原创一般采用分词引擎以及动态同义词库,模拟百度(baidu),谷歌(google)等中文切词进行伪原创,生成后的伪原创文章更准确更贴近百度和 ...

  7. TI CC2541增加一个可读写, 又可以Notify的特征字

    参考这个博客: http://blog.csdn.net/feilusia/article/details/48235691 值得注意是, 测试前, 在手机中先取消对原有的设备的配对.

  8. org.apache.cxf.interceptor.Fault: No such operation

    webservice错误,访问的时候加后缀wsdl即可,如:http://localhost:9000/HelloWorld?wsdl

  9. 28、Oracle(四)用户权限控制

    一)用户Oracle中的用户分为二大类1)Oracle数据库服务器创建时,由系统自动创建的用户,叫系统用户,如sys.2)利用系统用户创建的用户,叫普通用户,如scott,hr,c##tiger,zh ...

  10. 关于childNodes的length的问题

    <ul id="ul1"> <li></li> <li></li> </ul> 这个时候如果 documen ...