Pagini recente » Cod sursa (job #1383659) | Cod sursa (job #3218277) | Cod sursa (job #1379516) | Cod sursa (job #1545505) | Cod sursa (job #976140)
Cod sursa(job #976140)
#include<fstream>
#include<cmath>
#include<vector>
#include<algorithm>
#define x first
#define y second
#define NM 100100
using namespace std;
ifstream f("cmap.in");
ofstream g("cmap.out");
vector<pair<double,double> >v(NM);
double dist(int a,int b)
{
return sqrt((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 n,i,j;
double d;
int main ()
{
f>>n;
for(i=0;i<n;++i)
f>>v[i].x>>v[i].y;
sort(v.begin(),v.begin()+n-1);
d=1<<25;
for(i=0;i<n;++i)
for(j=i+1;j<n;++j)
{
if(dist(i,j)>d)
break;
if(dist(i,j)<d)
d=dist(i,j);
}
g<<d;
return 0;
}