Cod sursa(job #1151041)

Utilizator manutrutaEmanuel Truta manutruta Data 23 martie 2014 20:09:11
Problema Cele mai apropiate puncte din plan Scor 20
Compilator cpp Status done
Runda Arhiva educationala Marime 0.79 kb
#include <cmath>
#include <iostream>
#include <fstream>
#include <iomanip>

using namespace std;
#define LL long long
#define x first
#define y second

#define INF (1LL << 62)
#define MAXN 100000

ifstream f("cmap.in");
ofstream g("cmap.out");

int n;
pair<LL, LL> pt[MAXN];

LL dist(int i, int j) {
    return 1LL * (pt[i].x - pt[j].x) * (pt[i].x - pt[j].x) + 1LL * (pt[i].y - pt[j].y) * (pt[i].y - pt[j].y);
}

int main()
{
    f >> n;
    for (int i = 1; i <= n; i++) {
        f >> pt[i].x >> pt[i].y;
    }

    LL mn = INF;
    for (int i = 1; i < n; i++) {
        for (int j = i + 1; j <= n; j++) {
            mn = min(mn, dist(i, j));
        }
    }

    g << fixed << setprecision(6) << sqrt(mn) << '\n';

    f.close();
    g.close();
    return 0;
}