标签:
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <cstdlib>
using namespace std;
typedef long long ll;
const int N = 105;
const int INF = 0x3f3f3f3f;
int n;
double G[N][N];
double X[N], Y[N];
double dis(int x, int y) {
return ((X[x] - X[y]) * (X[x] - X[y]) + (Y[x] - Y[y]) * (Y[x] - Y[y]));
}
void floyd() {
for (int k = 0; k < n; k++) {
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
if (G[i][j] > G[i][k] + G[k][j]) {
G[i][j] = G[i][k] + G[k][j];
}
}
}
}
}
int main() {
int T, Case = 1;
scanf("%d", &T);
while (T--) {
printf("Case #%d:\n", Case++);
for (int i = 0; i < N; i++) {
for (int j = 0; j < N; j++) {
G[i][j] = INF;
}
}
scanf("%d", &n);
int a, b;
for (int i = 0; i < n; i++) {
scanf("%lf %lf", &X[i], &Y[i]);
}
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
if (i == j) {
G[i][j] = INF;
continue;
}
G[i][j] = sqrt(dis(i, j));
if (G[i][j] > 10.0) G[i][j] = INF;
}
}
floyd();
double ans = 0;
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
if (G[i][j] > ans) ans = G[i][j];
}
}
if (INF - ans < 1e-9) printf("Send Kurdy\n");
else printf("%.4lf\n", ans);
printf("\n");
}
return 0;
}
版权声明:本文为博主原创文章,未经博主允许不得转载。
uva 10803 Thunder Mountain (floyd)
标签:
原文地址:http://blog.csdn.net/llx523113241/article/details/47041271