标签:
#include <iostream>
#include<string.h>
using namespace std;
int p[1000][1000];
int Max(int a,int b){
return a > b ? a:b;
}
int main()
{
int c = 0;
int n = 0;
int i = 0,j = 0;
memset(p,0,sizeof(p));
cin >> c;
while(c--){
cin >> n;
for(i = 0;i < n;i++)
for(j = 0;j <= i;j++)
cin >> p[i][j];
for(i = n-2;i >=0;i--)
for(j = 0;j <=i;j++){
p[i][j] = Max(p[i+1][j],p[i+1][j+1]) + p[i][j];
}
cout << p[0][0] << endl;
}
return 0;
}
标签:
原文地址:http://www.cnblogs.com/2016zhanggang/p/5483716.html