最近点对 。
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <math.h>
using namespace std;
#define sf scanf
#define pf printf
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define dbg(x) cerr << "__LINE__" << " : " << #x << " : " << (x) << endl
#define nMax 1000100
typedef double D;
D const eps = 1e-8;
int dcmp(double x) {
if( x>-eps && x<eps) return 0;
return x > 0 ? 1 : -1;
}
struct P{
double x,y;
P () {};
P (double x,double y):x(x),y(y){};
void read () { sf("%lf%lf",&x,&y); }
D dist() { return sqrt(x*x + y*y); }
};
P operator + (const P& u,const P& v) { return P(u.x+v.x,u.y+v.y); }
P operator - (P const& u,P const& v) { return P(u.x-v.x,u.y-v.y); }
P operator * (P const& u, double k ) { return P(u.x * k,u.y * k); }
P operator / (P const& u, double k ) { return P(u.x / k,u.y / k); }
D operator * (P const& u,P const& v) { return u.x*v.y - u.y*v.x; }
D operator ^ (P const& u,P const& v) { return u.x*v.x + u.y*v.y; }
int n;
P a[nMax];
int s[nMax];
int cmpx(int i,int j) {
return a[i].x < a[j].x ;
}
int cmpy(int i,int j) {
return a[i].y < a[j].y;
}
double min_dist(int l,int r) {
double ans = 1e10;
if(r-l < 20) {
for(int q=l;q<r;q++)
for(int w=q+1;w<r;w++) ans = min((a[s[q]]-a[s[w]]).dist(),ans);
return ans;
}
int tl,tr,m=(l+r)/2;
ans = min(min_dist(l,m),min_dist(m,r));
for(tl=l;a[s[tl]].x<a[s[m]].x-ans && tl<m;tl++);
for(tr=r-1;a[s[tr]].x>a[s[m]].x+ans && tr>=m;tr--);
sort(s+tl,s+tr,cmpy);
for(int q=tl;q<tr;q++)
for(int w=q+1;w<min(tr,q+6);w++)
ans = min(ans,(a[s[q]]-a[s[w]]).dist());
sort(s+tl,s+tr,cmpx);
return ans;
}
int main() {
#ifndef ONLINE_JUDGE
freopen("in.txt","r",stdin);
#endif
while(~sf("%d",&n),n) {
if(n==0) break;
rep(i,n) a[i].read();
rep(i,n) s[i]=i;
sort(s,s+n,cmpx);
// dbg(n);
D ans = min_dist(0,n);
pf("%.2lf\n",ans/2.0);
}
return 0;
}