# hdu 1007

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <iomanip>

using namespace std;

const int MAXN = 100100;

struct Point
{
double x, y;
};

Point point[MAXN];
Point s[MAXN];
int cmp(Point a, Point b)
{
return a.x < b.x;
}

int cmp1(Point a, Point b)
{
return a.y < b.y;
}

double Calculate(Point a, Point b)
{
return sqrt( (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y) );
}

double Binary_search(int a, int b)
{
int i, j;
if(b - a == 1)
return Calculate(point[a], point[b]);
if(b - a == 2)
return min( Calculate(point[a], point[a+1]), min(Calculate(point[a], point[b]), Calculate(point[a+1], point[b])) );
int mid = (a + b) / 2;
double m = min(Binary_search(a, mid), Binary_search(mid+1, b));
for(i = mid-1; i >= a; --i)
{
if (point[mid].x - point[i].x >= m)
{
a = i;
break;
}
}
for (i = mid; i <= b; ++i)
{
if (point[i].x - point[mid-1].x >= m)
{
b = i;
break;
}
}
int cnt = 0;
for (i = a; i <= b; ++i)
s[cnt++] = point[i];
sort(s, s+cnt, cmp1);
for (i = 0; i < cnt; ++i)
{
for (j = i+1; j < cnt; ++j)
{
if(s[j].y - s[i].y > m)//在中位线上的投影小于m的值
break;
if(Calculate(s[i], s[j]) < m)
m = Calculate(s[i], s[j]);
}
}
return m;
}

int main()
{
int n;
while (cin>>n, n)
{
for (int i = 0; i < n; ++i)
cin>>point[i].x>>point[i].y;
sort(point, point+n, cmp);
cout<<setiosflags(ios::fixed)<<setprecision(2)<<Binary_search(0, n-1)/2<<endl;
}
return 0;
}


#### hdu1007最近点对（分治）

2016-09-19 16:43:12

#### 杭电ACM第1007题——Quoit Design

2017-03-23 14:30:27

#### hdu 1007 经典最近点对 （分治法求解）

2011-08-31 23:27:15

#### HDU-1007 Quoit Design

2016-05-20 10:14:30

#### HDU1007(求最近两个点之间的距离)

2015-03-16 10:28:50

#### 杭电OJ 1007 Quoit Design

2017-04-21 19:38:10

#### hdu-1007-Quoit Design-求最小点距离、分治思想

2016-08-12 00:01:16

#### 分治法求最小点对（hdu1007）

2011-07-23 12:20:02

#### HDU1007——二维空间最近点对问题（分治）

2014-03-19 19:28:34

#### 杭电OJ——1007 Quoit Design(最近点对问题)

2013-06-24 14:03:15