SY_Nightmare @ 2024-10-04 14:18:45
随便乱打的代码,不开02都能过。
#include<bits/stdc++.h>
#define pi acos(-1.0)
using namespace std;
struct node{double x,y;}a[200005];
int n;
double ans=1e15;
bool cmp(node a,node b){return a.x<b.x;}
double dis(node a,node b){return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));}
int main()
{
cin>>n;
for(int i=1;i<=n;i++) cin>>a[i].x>>a[i].y;
sort(a+1,a+1+n,cmp);
for(int i=1;i<=n;i++)
for(int j=i+1;j<=i+5&&j<=n;j++)
ans=min(ans,dis(a[i],a[j]));
cout<<fixed<<setprecision(4)<<ans;
return 0;
}
by SY_Nightmare @ 2024-10-04 17:50:04
@Texas_the_Omertosa
没事没事 不是对你说的 有疑问很正常 是对上面那个说的