/* Author: ACb0y Date: 2010年9月16日1:06:03 Type: MST Kruskal ProblemId: hdu 1162 Eddy's picture Result: 2960095 2010-09-16 01:04:47 Accepted 1162 15MS 480K 1267 B G++ ACb0y */ #include <iostream> #include <cmath> using namespace std; struct Point { double x; double y; }; struct edge { int x; int y; double w; }; int n; int g[110][110]; int father[110]; Point points[110]; edge edges[10100]; double get_dis(int a, int b) { return sqrt((points[a].x - points[b].x) * (points[a].x - points[b].x) + (points[a].y - points[b].y) * (points[a].y - points[b].y)); } int cmp(const void * a, const void * b) { edge * pa = (edge *) a; edge * pb = (edge *) b; return pa->w > pb->w ? 1 : -1; } int find(int x) { if (x != father[x]) { return find(father[x]); } return x; } int main() { int i, j; #ifndef ONLINE_JUDGE freopen("1162.txt", "r", stdin); #endif while (cin >> n) { for (i = 1; i <= n; i++) { scanf("%lf%lf", &points[i].x, &points[i].y); } int c = 0; for (i = 1; i <= n; i++) { for (j = 1; j <= n; j++) { edges[c].w = get_dis(i, j); edges[c].x = i; edges[c].y = j; c++; } } qsort(edges, c, sizeof(edge), cmp); for (i = 1; i <= n; i++) { father[i] = i; } double ans = 0; for (i = 0; i < c; i++) { int x = find(edges[i].x); int y = find(edges[i].y); if (x != y) { ans += edges[i].w; father[x] = y; } } printf("%.2lf/n", ans); } return 0; }