解题思路:
注意事项:
参考代码:
#include <cstdio> #include <cstring> #include <string> #include <cmath> #include <functional> #include <iostream> #include <algorithm> using namespace std; const int maxn = 101; const int INF = -2100000000; int a[maxn][maxn], n, d[maxn][maxn]; int main() { scanf("%d", &n); for(int i = 1; i <= n; ++i) { for(int j = 1; j <= i; ++j) { scanf("%d", &a[i][j]); } } for(int i = 1; i <= n; ++i) { d[n][i] = a[n][i]; } for(int i = n-1; i >= 1; --i) { for(int j = 1; j <= i; ++j) { d[i][j] = a[i][j] + max(d[i+1][j],d[i+1][j+1]); } } printf("%d\n", d[1][1]); return 0; }
0.0分
0 人评分
【绝对值排序】 (C++代码)浏览:672 |
C语言程序设计教程(第三版)课后习题4.9 (C语言代码)浏览:904 |
校门外的树 (C语言代码)浏览:961 |
C语言程序设计教程(第三版)课后习题8.1 (C语言代码)浏览:529 |
WU-蓝桥杯算法提高VIP-企业奖金发放 (C++代码)浏览:1175 |
C语言程序设计教程(第三版)课后习题8.9 (C语言代码)浏览:832 |
C语言程序设计教程(第三版)课后习题9.10 (C语言代码)浏览:834 |
一元一次方程 (C语言代码)浏览:4069 |
简单的a+b (C语言代码)浏览:416 |
简单的事情 (C语言代码)浏览:638 |