Pagini recente » Cod sursa (job #869641) | Cod sursa (job #2462317) | Cod sursa (job #624658) | Cod sursa (job #453416) | Cod sursa (job #2089123)
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;
ifstream q("cmap.in");
ofstream w("cmap.out");
struct pct{
int x,y;
}v[100100];
vector<pct> aux;
bool crescator(pct a, pct b)
{
return (a.x<b.x);
}
double distanta(pct p1, pct p2)
{
return sqrt((double)((p1.x-p2.x)*(p1.x-p2.x)+(p1.y-p2.y)*(p1.y-p2.y)));
}
int main()
{
int n;
double min=1000000000.0;
q>>n;
q>>v[1].x>>v[1].y;
aux.push_back(v[1]);
for(int i=2;i<=n;i++)
{
q>>v[i].x>>v[i].y;
aux.push_back(v[i]);
}
sort(aux.begin(),aux.end(),crescator);
int lm = aux.size()/2; ///Acesta este dreapta x=lm a.i. sa avem diferenta intre Ps si Pd de maxim 1
for(int i=1;i<n;i++)
for(int j=i+1;j<=n;j++)
{
double dist = distanta(v[i],v[j]);
if(dist<min) min=dist;
}
w<<setprecision(6)<<fixed<<min;
return 0;
}