Cod sursa(job #1235786)

Utilizator armandpredaPreda Armand armandpreda Data 30 septembrie 2014 17:59:20
Problema Cele mai apropiate puncte din plan Scor 20
Compilator cpp Status done
Runda Arhiva educationala Marime 0.87 kb
#include <cstdio>
#include <cmath>
#define eps 1.e-6
#define INF 1.e9

using namespace std;

class POINT
{
    private:
        double x,y;
    public:
        void set(int a,int b)
        {
            x=a;y=b;
        }
        double dist(const POINT & other)
        {
            return sqrt((double)((long long)((long long)x-other.x)*(x-other.x)+(long long)((long long)y-other.y)*(y-other.y)));
        }
};
POINT v[100005];
int main()
{
    freopen("cmap.in","r",stdin);
    freopen("cmap.out","w",stdout);
    int n,a,b,i,j;
    double d,min=INF;
    scanf("%d",&n);
    for(i=1;i<=n;++i)
    {
        scanf("%d%d",&a,&b);
        v[i].set(a,b);
    }
    for(i=1;i<=n;++i)
        for(j=i+1;j<=n;++j)
        {
            d=v[i].dist(v[j]);
            if(d<min)
                min=d;
        }
    printf("%lf",min);
    return 0;
}