#include <iostream> #include <stdio.h> #include <cstring> #include <algorithm> #include <cmath> using namespace std; const int maxn = 1001; int D[maxn][maxn]; int DP[maxn][maxn]; int main() { int n, quan; cin >> quan; while (quan--) { cin >> n; for (int i = 1; i <= n; i++) for (int j = 1; j <= i; j++) cin >> D[i][j]; for (int i = 1; i <= n; i++) DP[n][i] = D[n][i]; for(int i=n-1;i>=1;i--) for (int j = 1; j <= i; j++) { DP[i][j] = max(DP[i + 1][j], DP[i + 1][j + 1]) + D[i][j]; } cout << DP[1][1] << endl; } return 0; }
0.0分
0 人评分
数组输出 (C语言代码)浏览:767 |
C语言训练-求s=a+aa+aaa+aaaa+aa...a的值 (C语言代码)浏览:1031 |
C语言程序设计教程(第三版)课后习题11.1 (C语言代码)浏览:633 |
C语言训练-计算t=1+1/2+1/3+...+1/n (C语言代码)浏览:868 |
【亲和数】 (C语言代码)浏览:495 |
C语言程序设计教程(第三版)课后习题10.4 (C语言代码)浏览:675 |
WU-整数平均值 (C++代码)浏览:1244 |
母牛的故事 (C语言代码)浏览:1428 |
C语言程序设计教程(第三版)课后习题4.9 (C语言代码)浏览:689 |
简单的a+b (C语言代码)浏览:486 |