hd1007

#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std; struct node
{
double x,y;
}point[];
int n; bool hAlignLess(node p1,node p2)
{
if(p1.x != p2.x) return p1.x < p2.x;
else return p1.y < p2.y;
} double getDist(node p1, node p2)
{
return sqrt((p1.x - p2.x)*(p1.x - p2.x) + (p1.y - p2.y)*(p1.y - p2.y));
} double getMin(double a, double b)
{
return a<b?a:b;
} double solve(int l,int r)
{
if(l == r)
return ;
if(l == r - )
return getDist(point[l],point[r]);
if(l == r - )
return getMin(getMin(getDist(point[l],point[l+]),getDist(point[l+],point[l+])),getDist(point[l],point[l+]));
int i,j,mid = (l+r) >> ;
double curmin = getMin(solve(l,mid),solve(mid+,r));
for(i=l;i<=r;i++)
for(j=i+;j<=i+ && j<=r;j++)
{
curmin = getMin(curmin,getDist(point[i],point[j]));
}
return curmin;
} int main() {
int i;
while(scanf("%d",&n)!=EOF && n){
for(i = ; i < n; i++){
scanf("%lf %lf",&point[i].x,&point[i].y);
}
sort(point,point+n,hAlignLess);
double ans = solve(,n-);
printf("%.2lf\n",ans/);
}
return ;
}
上一篇:调试CGI python


下一篇:牛客小白赛1 F题三视图