Pagini recente » Cod sursa (job #369987) | Cod sursa (job #3131029) | Cod sursa (job #1087369) | Cod sursa (job #2332639) | Cod sursa (job #1487183)
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
using namespace std;
int n;
vector< pair<int,int> > v;
bool cmp(pair<int,int> A,pair<int,int> B)
{
if(A.first<B.first)
return true;
if(A.first==B.first)
return A.second<B.second;
return false;
}
void read()
{
scanf("%d ",&n);
int x,y;
for(int i=0;i<n;i++)
{
scanf("%d %d",&x,&y);
v.push_back(make_pair(x,y));
}
sort(v.begin(),v.begin()+n,cmp);
}
double dist(pair<int,int>A,pair<int,int> B)
{
double x,y;
x = A.first-B.first;
x *=x;
y =A.second-B.second;
y *=y;
return sqrt(x+y);
}
double impera(int st, int dr)
{
if(st+1==dr)
return dist(v[st],v[dr]);
int mij=(st+dr)/2;
return min(impera(st,mij),impera(mij,dr));
}
int main()
{
freopen("cmap.in","r",stdin);
freopen("cmap.out","w",stdout);
read();
printf("%lf ",impera(0,n-1));
return 0;
}