Pagini recente » Cod sursa (job #220786) | Cod sursa (job #2635038) | Cod sursa (job #2573604) | Cod sursa (job #1059365) | Cod sursa (job #1958509)
#include <fstream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <climits>
using namespace std;
ifstream fin("cmap.in");
ofstream fout("cmap.out");
#define nmax 100005
struct punct
{
long long x, y;
};
punct make_punct(long long x, long long y)
{
punct a;
a.x=x; a.y=y;
return a;
}
long double dst(punct a, punct b)
{
return sqrt((a.x-b.x)*(a.x-b.x) + (a.y-b.y)*(a.y-b.y));
}
bool cmpf(punct a, punct b)
{
return dst(make_punct(-1000000000, -1000000000), a)<dst(make_punct(-1000000000, -1000000000), b);
/*
if(a.x==b.x)
return a.y<b.y;
return a.x<b.x;*/
}
int n;
long double dmin=INT_MAX;
punct v[nmax];
void citire()
{
int i;
fin>>n;
for(i=1; i<=n; i++)
fin>>v[i].x>>v[i].y;
fin.close();
}
void solve()
{
int i;
long double d;
for(i=1; i<n; i++)
{
d=dst(v[i], v[i+1]);
if(d<dmin)
dmin=d;
}
}
int main()
{
citire();
sort(v+1, v+1+n, cmpf);
solve();
fout<<fixed<<setprecision(6)<<dmin<<'\n';
fout.close();
return 0;
}