Pagini recente » Cod sursa (job #1317983) | Cod sursa (job #648552) | Cod sursa (job #2285029) | Statistici Groita Igor (igroita) | Cod sursa (job #1645733)
#include <fstream>
#include <cmath>
#include <algorithm>
#include <iomanip>
using namespace std;
struct punct
{
long double x, y;
};
punct v[100005];
bool cmp (punct a, punct b)
{
if (a.x < b.x)
return 1;
else
return 0;
}
long double dist (punct a, punct b)
{
double l;
l = (a.x-b.x)*(a.x-b.x) + (a.y-b.y)*(a.y-b.y);
return sqrt(l);
}
int main ()
{
ifstream fin ("cmap.in");
ofstream fout ("cmap.out");
int n, j;
fin >> n;
int i;
for (i=1; i<=n; i++)
fin >> v[i].x >> v[i].y;
sort(v+1,v+n+1,cmp);
long double mi, w;
mi = dist(v[1],v[2]);
for (i=3; i<=n; i++)
{
j = i-1;
while (v[i].x-v[j].x < mi and j>=1)
{
w = dist (v[i],v[j]);
if (mi > w)
mi = w;
j -= 1;
}
}
fout << fixed << setprecision(6) << mi;
return 0;
}