Descriptionios
Inputapp
Outputide
1 #include <iostream> 2 #include <algorithm> 3 #include <deque> 4 #include <cstdio> 5 #include <cstring> 6 #include <cmath> 7 8 using namespace std; 9 10 const int sz = 201; 11 const double inf = 10.0e8; 12 double d[sz][sz], x[sz], y[sz]; 13 int n; 14 15 void get_dist(int i, int j) 16 { 17 d[i][j] = d[j][i] = sqrt((x[i] - x[j]) * (x[i] - x[j]) + 18 (y[i] - y[j]) * (y[i] - y[j])); 19 } 20 21 void floyd() 22 { 23 for(int k = 1; k <= n; k++){ 24 for(int i = 1; i <= n; i++){ 25 for(int j = 1; j <= n; j++){ 26 d[i][j] = min(d[i][j], max(d[i][k], d[k][j])); 27 } 28 } 29 } 30 } 31 32 int main() 33 { 34 int ca = 1; 35 while(scanf("%d", &n) && n){ 36 for(int i = 1; i <= n; i++){ 37 for(int j = 1; j <= n; j++){ 38 d[i][j] = inf; 39 } 40 d[i][i] = 0.0; 41 } 42 for(int i = 1; i <= n; i++){ 43 scanf("%lf %lf", x + i, y + i); 44 for(int j = i - 1; j > 0; j--){ 45 get_dist(i, j); 46 } 47 } 48 floyd(); 49 printf("Scenario #%d\nFrog Distance = %.3lf\n\n", ca++, d[1][2]); 50 } 51 return 0; 52 }