#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int nasce,n,max_two;
int number[101][101];
void DP()
{
for(int i = n -2; i >= 0; i--)
for(int j = 0; j < i + 1; j++)
{
max_two = number[i + 1][j];
if(max_two < number[i + 1][j + 1])
max_two = number[i + 1][j + 1];
number[i][j] += max_two;
}
printf("%d\n",number[0][0]);
}
int main()
{
scanf("%d",&nasce);
while(nasce--)
{
scanf("%d",&n);
memset(number,0,sizeof(number));
for(int i = 0; i < n; i++)
for(int j = 0; j < i + 1; j++)
scanf("%d",&number[i][j]);
DP();
}
return 0;
}
HDU-2084 数塔
最新推荐文章于 2020-03-21 19:14:31 发布