标签:

1 5 7 3 8 8 1 0 2 7 4 4 4 5 2 6 5
30
#include <iostream>
#include <string>
using namespace std;
const int MAXX = 105;
int tower[MAXX][MAXX];
int max(int x, int y){
if (x > y)return x;
return y;
}
void solve(int n){
for (int i = n - 1; i >= 0; --i){
for (int j = 0; j <= i; ++j){
tower[i][j] += max(tower[i + 1][j], tower[i + 1][j + 1]);
}
}
}
int main(){
//freopen("in.txt", "r", stdin);
int c, n;
cin >> c;
while (c--){
cin >> n;
memset(tower, 0, sizeof(tower));
for (int i = 0; i < n; ++i){
for (int j = 0; j < n; ++j){
if (i >= j)cin >> tower[i][j];
}
}
solve(n);
printf("%d\n",tower[0][0]);
}
}版权声明:本文博主原创文章。博客,未经同意不得转载。
标签:
原文地址:http://www.cnblogs.com/bhlsheji/p/4814134.html