Pagini recente » Cod sursa (job #2963325) | Cod sursa (job #2687222) | Cod sursa (job #2538772) | Cod sursa (job #1479910) | Cod sursa (job #2089029)
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
using namespace std;
int N;
struct punct
{
double x,y;
double dist(punct p)
{
return sqrt((this->x-p.x)*(this->x-p.x)+(this->y-p.y)*(this->y-p.y));
}
}vPuncte[100005];
bool cmp(punct p1,punct p2)
{
return p1.x<p2.x;
}
void citire()
{
scanf("%d",&N);
for(int i=1;i<=N;i++)
{
scanf("%lf%lf",&vPuncte[i].x,&vPuncte[i].y);
}
sort(vPuncte+1,vPuncte+N+1,cmp);
}
double distPeSemiplan(int st,int dr)
{
if(dr-st==2)
{
return min(vPuncte[st].dist(vPuncte[dr-1]),vPuncte[st+1].dist(vPuncte[dr]));
}
if(dr-st==1)
{
return vPuncte[st].dist(vPuncte[dr]);
}
return min(distPeSemiplan(st,(st+dr)/2),distPeSemiplan((st+dr)/2,dr));
}
int main()
{
freopen("cmap.in","r",stdin);
freopen("cmap.out","w",stdout);
citire();
printf("%lf",distPeSemiplan(1,N));
return 0;
}