Pagini recente » Cod sursa (job #3224657) | Cod sursa (job #1295662) | Cod sursa (job #2395211) | Cod sursa (job #35821) | Cod sursa (job #1684021)
#include <fstream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#define pdd pair< double, double >
#define x first
#define y second
using namespace std;
ifstream fi("cmap.in");
ofstream fo("cmap.out");
const int Mn = 1e5 + 6;
int n;
double ans;
pdd ar[Mn];
bool comp(pdd a,pdd b)
{
if (a.x != b.x)
return a.x < b.x;
return a.y < b.y;
}
double dist(pdd a,pdd b)
{
return sqrt((b.x - a.x) * (b.x - a.x) + (b.y - a.y) * (b.y - a.y));
}
int main()
{
fi >> n;
for (int i = 1; i <= n; i++)
fi >> ar[i].x >> ar[i].y;
sort(ar + 1, ar + 1 + n);
ans = dist(ar[1], ar[2]);
for (int i = 1; i <= n; i++)
for (int j = i + 1; j <= n; j++)
{
double d1 = dist(ar[i], ar[j]);
if (d1 > ans)
break;
ans = min(ans, d1);
}
fo << setprecision(18) << ans << endl;
}