Pagini recente » Cod sursa (job #875591) | Cod sursa (job #2257926) | Cod sursa (job #1005313) | Cod sursa (job #780078) | Cod sursa (job #2089106)
#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 A, pct B)
{
return sqrt((double)((long long)((long long)((A.x-B.x)*(A.x-B.x))+(long long)((A.y-B.y)*(A.y-B.y)))));
}
int main()
{
int n;
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
double min=distanta(v[1],v[2]); // trebuie sa initializam si noi cu ceva
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;
}