分治做法还不会,以后再补、、、
https://www.luogu.com.cn/problem/P1257
https://www.luogu.com.cn/problem/P1429
https://www.luogu.com.cn/problem/P7883
//随机坐标旋转一定角度,然后按照x或y进行排序,从前往后找k个点即可,k == 5的时候就ac了。。。。。。
//旋转角度公式: //x'=xcosθ-ysinθ
//y'=xsinθ+ycosθ
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e6+9;
struct Point {
long double x,y;
}Points[N];
bool operator < (Point a,Point b) {
if(a.x != b.x) return a.x < b.x;
return a.y < b.y;
}
long double get_dis(int p,int q) {
long double dx = Points[p].x - Points[q].x;
long double dy = Points[p].y - Points[q].y;
return sqrtl(dx * dx + dy * dy);
}
int main() {
int n;
cin >> n;
for(int i=1; i<=n; i++) {
long double x,y,x_,y_;
scanf("%LF%LF",&x,&y);
x_ = x,y_ = y;
x = x_ * cosl(1) - y_ * sinl(1),y = x_ * sinl(1) + y_ * cosl(1);
Points[i] = {x,y};
}
sort(Points+1,Points+n+1);
long double ans = 2e18;
for(int i=1; i<=n; i++) {
for(int j=i+1; j<=n && j <= i+5; j++) {
ans = min(ans,get_dis(i,j));
}
}
printf("%.4LF\n",ans);
return 0;
}