Pagini recente » Cod sursa (job #1606134) | Cod sursa (job #3205041) | Cod sursa (job #735555) | Cod sursa (job #20275) | Cod sursa (job #1908366)
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#define x first
#define y second
using namespace std;
ifstream cin ("cmap.in");
ofstream cout("cmap.out");
vector <pair<int, int> > a;
void read()
{
int n, x, y;
cin >> n;
a.resize(n);
for (int i = 0; i < a.size(); i++)
cin >> a[i].x >> a[i].y;
}
bool f(pair<long long, long long> x, pair<long long, long long> y)
{
return x.x < y.x;
}
double dist(pair<long long, long long> x, pair<long long, long long> y)
{
return sqrt((x.x - y.x) * (x.x - y.x) + (x.y - y.y) * (x.y - y.y));
}
double solve()
{
sort(a.begin(), a.end(), f);
double d = dist(a[0], a[1]);
for (int i = 0; i < a.size(); i++)
for (int j = i + 1; a[j].x - a[i].x < d && j < a.size(); j++)
d = min(d, dist(a[i], a[j]));
return d;
}
int main()
{
read();
cout << fixed << setprecision(10) << solve() ;
return 0;
}