/* Author: ACb0y Date: 2010-9-15 Type: MST ProblemId: hdu 1875 畅通工程再续 Result: AC */ #include <iostream> #include <cmath> using namespace std; #define inf 999999999.9 struct Point { double x; double y; }; int n; Point points[110]; double g[110][110]; double d[110]; int vis[110]; 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)); } void MST_Prim() { int i, j; memset(vis, 0, sizeof(vis)); for (i = 1; i <= n; i++) { d[i] = g[1][i]; } d[1] = 0.0; double ans = 0.0; int flag = 1; for (i = 1; i <= n; i++) { double Min = inf; int pos = -1; for (j = 1; j <= n; j++) if (!vis[j]) { if (d[j] < Min) { Min = d[j]; pos = j; } } if (Min == inf) { flag = 0; break; } ans += Min; vis[pos] = 1; for (j = 1; j <= n; j++) { if (g[pos][j] < d[j]) { d[j] = g[pos][j]; } } } if (!flag) { cout << "oh!" << endl; } else { printf("%0.1lf/n", ans * 100); } } int main() { int cas; int i, j; #ifndef ONLINE_JUDGE freopen("1875.txt", "r", stdin); #endif cin >> cas; while (cas--) { cin >> n; for (i = 1; i <= n; i++) { scanf("%lf%lf", &points[i].x, &points[i].y); } for (i = 1; i <= n; i++) { for (j = 1; j <= n; j++) { double temp = get_dis(i, j); if (temp >= 10.0 && temp <= 1000.0) { g[i][j] = g[j][i] = temp; } else { g[i][j] = g[j][i] = inf; } } } MST_Prim(); } return 0; }