P1216 [USACO1.5][IOI1994]数字三角形 Number Triangles

很简单的一道dp
首先看一下数据范围,1e3可以开个二维的
然后思考状态转移方程,设位置i,j,一般情况下,[i][j]由位置[i-1][j-1]和[i-1][j]转移过来的,然后在考虑边缘位置,就可以了
#include
using namespace std;
const int maxn = 1005;
int a[maxn][maxn], dp[maxn][maxn];
int main(){
int n;
cin >> n;
for(int i = 1; i <= n; i++){ for(int j = 1; j <= i; j++){ cin >> a[i][j];
}
}
dp[1][1] = a[1][1];
for(int i = 2; i <= n; i++){ for(int j = 1; j <= i; j++){ if(j == 1) dp

P1216 [USACO1.5][IOI1994]数字三角形 Number Triangles最先出现在Python成神之路

版权声明:
作者:ht
链接:https://www.techfm.club/p/19843.html
来源:TechFM
文章版权归作者所有,未经允许请勿转载。

THE END
分享
二维码
< <上一篇
下一篇>>