Pagini recente » Cod sursa (job #1252612) | Cod sursa (job #487097) | Cod sursa (job #3039772) | Cod sursa (job #1962633) | Cod sursa (job #2149075)
#include <bits/stdc++.h>
#define ld long double
using namespace std;
ifstream f("cmap.in");
ofstream g("cmap.out");
const int NMax = 100001;
const ld INF = 10000000000;
struct point{
ld x,y;
};
point a[NMax];
int n;
bool cmp(point x, point y){
return (x.x < y.x);
}
ld dist(point a, point b){
return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));
}
int main()
{
f >> n;
for(int i = 1; i <= n; ++i)
f >> a[i].x >> a[i].y;
sort(a + 1, a + 1 + n,cmp);
ld t = INF;
for(int i = 1; i <= n; ++i){
for(int j = i + 1; j <= n; ++j){
if(a[j].x - a[i].x > t)
break;
t = min(t,dist(a[i],a[j]));
}
}
g << fixed << setprecision(6) << t << '\n';
return 0;
}