Cod sursa(job #655460)

Utilizator titeltitel popescu titel Data 2 ianuarie 2012 17:28:49
Problema Cele mai apropiate puncte din plan Scor 20
Compilator cpp Status done
Runda Arhiva educationala Marime 0.59 kb
// solutie de 40 puncte
#include<fstream>
#include<math.h>
#define nmax 100002
#define LL long long
using namespace std;
ifstream f("cmap.in"); ofstream g("cmap.out");
struct punct {LL x,y;} v[nmax];
int n;
double d,dmin;
double dist(int p, int q)
{return sqrt((double)(v[p].x-v[q].x)*(v[p].x-v[q].x)+(double)(v[p].y-v[q].y)*(v[p].y-v[q].y));}

int main()
{	f>>n;	
	for(int i=1;i<=n;i++) f>>v[i].x>>v[i].y;
	dmin=10000000000.0;
	for(int i=1;i<n;i++)
		for(int j=i+1;j<=n;j++)
			{d=dist(i,j);
			 if(d<dmin) dmin=d;	
			}
	g.precision( 16 ); g<<dmin<<'\n';
	g.close(); return 0;
}