Posted on 2008-05-28 10:17
superman 阅读(532)
评论(1) 编辑 收藏 引用 所属分类:
ZOJ
1 /* Accepted 1942 C++ 00:00.22 1160K */
2 #include <math.h>
3 #include <iostream>
4
5 using namespace std;
6
7 int main()
8 {
9 cout.setf(ios_base::showpoint);
10 cout.setf(ios_base::fixed);
11 cout.precision(3);
12
13 int n, cnt = 1;
14 while(cin >> n && n)
15 {
16 struct { int x, y; } p[200];
17 for(int i = 0; i < n; i++)
18 cin >> p[i].x >> p[i].y;
19
20 double dist[200][200] = { 0.0 };
21
22 for(int i = 0; i < n; i++)
23 for(int j = 0; j < n; j++)
24 dist[i][j] = pow(p[i].x - p[j].x, 2.0) + pow(p[i].y - p[j].y, 2.0);
25 for(int k = 0; k < n; k++)
26 for(int i = 0; i < n; i++)
27 for(int j = 0; j < n; j++)
28 dist[i][j] <?= max(dist[i][k], dist[k][j]);
29 cout << "Scenario #" << cnt++ << endl;
30 cout << "Frog Distance = " << sqrt(dist[0][1]) << endl << endl;
31 }
32
33 return 0;
34 }
35