Pagini recente » Cod sursa (job #576030) | Cod sursa (job #2476466) | Cod sursa (job #1351415) | Cod sursa (job #2177052) | Cod sursa (job #2919970)
#include <bits/stdc++.h>
#include <math.h>
#include <stdlib.h>
#define x first
#define y second
using namespace std;
ifstream f("cmap.in");
ofstream g("cmap.out");
pair<double,double> v[1<<17];
double D(int a, int b) {
return sqrt(pow((v[a].x-v[b].x),2) + pow((v[a].y-v[b].y),2));
}
int n;
double t;
int main() {
double aplha = (rand() % 1000) * 8e-3 * atan(1);
double s,c;
s = sin(alpha), c = cos(alpha);
f>>n;
for(int i=1; i<=n; ++i) {
double x, y;
f >> x >> y;
v[i].x = c * x + s * y;
v[i].y = -s * x + c * y;
}
sort(v+1,v+n+1);
t=1000000000;
for(int i=1; i<=n; ++i)
for(int j=i+1; j<=n; ++j) {
if(v[j].x-v[i].x>t) break;
t=min(t,D(i,j));
}
g<<fixed<<setprecision(6)<<t;
return 0;
}