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

尚待理解

 1 #include <stdio.h>
 2 #include <string.h>
 3 #include <stdlib.h>
 4 #include <iostream>
 5 #include <algorithm>
 6 #include <math.h>
 7 #define MAXX 100005
 8 using namespace std;
 9 
10 
11 struct point
12 {
13     double x;
14     double y;
15 }p[MAXX],p1[MAXX],p2[MAXX];
16 
17 bool cmpx(point a,point b)
18 {
19     return a.x < b.x;
20 }
21 bool cmpy(point a,point b)
22 {
23     return a.y < b.y;
24 }
25 double dis(point a,point b)
26 {
27     return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
28 }
29 double minn(double a,double b)
30 {
31     return a > b ? b : a;
32 }
33 double closest(int l,int r)
34 {
35     if(l+1 == r)return dis(p1[l],p1[r]);
36     if(l+2 == r)
37         return minn(dis(p1[l],p1[l+1]),minn(dis(p1[l],p1[r]),dis(p1[l+1],p1[r])));
38     int mid=(l+r)>>1;
39     double ans=minn(closest(l,mid),closest(mid+1,r));
40     int cn=0;
41     for(int i=l; i<=r; i++)
42     {
43         if(p1[i].x>=p1[mid].x-ans&&p1[i].x<=p1[mid].x+ans)
44         {
45             p2[cn++]=p1[i];
46         }
47     }
48     sort(p2,p2+cn,cmpy);
49     for(int i=0; i<cn; i++)
50     {
51         for(int j=i+1; j<cn; j++)
52         {
53             if(p2[j].y-p2[i].y>=ans)
54                 break;
55             ans=minn(ans,dis(p2[i],p2[j]));
56         }
57     }
58     return ans;
59 }
60 
61 int main()
62 {
63 
64     int n;
65     while(scanf("%d",&n)!=EOF&&n)
66     {
67         for(int i=0; i<n; i++)
68         {
69             scanf("%lf%lf",&p[i].x,&p[i].y);
70             p1[i]=p[i];
71         }
72         sort(p1,p1+n,cmpx);
73         double dist=closest(0,n-1);
74         printf("%.2lf\n",dist/2);
75     }
76     return 0;
77 }