#include <iostream>
#include <algorithm>
using namespace std;
const int MAX = 110;
short dp[MAX][MAX];
int main()
{
int n, i, j;
while (cin >> n){
for (i = 1; i <= n; i++){
for (j = 1; j <= i; j++){
cin >> dp[i][j];
}
}
for(i = n-1; i >= 1; i--){
for(j = 1; j <= i; j++)
dp[i][j] += max(dp[i+1][j],dp[i+1][j+1]);
}
cout << dp[1][1] << endl;
}
system("pause");
}
poj 1163 The Triangle
最新推荐文章于 2020-06-28 17:35:24 发布