Posted on 2008-05-14 09:32
superman 阅读(245)
评论(0) 编辑 收藏 引用 所属分类:
ZOJ
1 /* Accepted 1291 C++ 00:00.00 880K */
2 #include <iostream>
3
4 using namespace std;
5 const int INF = 65535;
6
7 int main()
8 {
9 int N;
10 cin >> N;
11 while(N--)
12 {
13 int n;
14 cin >> n;
15
16 int d[100][100];
17 for(int i = 0; i < n; i++)
18 for(int j = 0; j < n; j++)
19 d[i][j] = INF;
20 for(int i = 1; i < n; i++)
21 for(int j = 0; j < i; j++)
22 if(scanf("%d", d[i] + j) == 1)
23 d[j][i] = d[i][j];
24 else
25 getchar();
26
27 for(int k = 0; k < n; k++)
28 for(int i = 0; i < n; i++)
29 for(int j = 0; j < n; j++)
30 d[i][j] <?= (d[i][k] + d[k][j]);
31
32 int ans = 0;
33 for(int i = 1; i < n; i++)
34 ans >?= d[0][i];
35
36 cout << ans << endl;
37
38 if(N)
39 cout << endl;
40 }
41
42 return 0;
43 }
44