Cod sursa(job #911764)

Utilizator dragangabrielDragan Andrei Gabriel dragangabriel Data 11 martie 2013 20:54:35
Problema Cele mai apropiate puncte din plan Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.68 kb
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
int n,i,j,k;
struct nod
{	int x;	int y;}v[100005];
long long rez;

int cmp(const nod a,const nod b)
{
	if (a.x==b.x) return a.y<b.y;
	return a.x<b.x;
}

long long calc(int a,int b)
{
	return (v[a].x-v[b].x)*(v[a].x-v[b].x)+(v[a].y-v[b].y)*(v[a].y-v[b].y);
}

int main()
{
	freopen("cmap.in","r",stdin);
    freopen("cmap.out","w",stdout);
	scanf("%d",&n);
	for (i=1;i<=n;i++) scanf("%d %d",&v[i].x,&v[i].y);
	sort(v+1,v+n+1,cmp);
	rez=calc(1,n);
	for (i=1;i<=n;i++)
		for (j=i+1;j<=i+7 && j<=n;j++)
			if (rez>calc(i,j)) rez=calc(i,j);
	printf("%6lf\n",sqrt((double)rez));
	return 0;
}