南阳oj The Triangle
来源:互联网 发布:经营之道软件攻略 编辑:程序博客网 时间:2024/05/14 17:56
动态规划基础,
从倒数第二排开始往前按照递推公式也就是状态转移方程往前推
i表示行,j表示列
状态转移方程为
C(i,j)=max(C(i+1,j),C(i+1,j+1))
ac代码如下
#include <iostream>#include <memory.h> #include <algorithm>using namespace std;int n;int dp[100][100];int main(){memset(dp,0,sizeof(dp));cin>>n;for(int i=0;i<n;i++){for(int j=0;j<=i;j++){cin>>dp[i][j];}}for(int i=n-2;i>=0;i--){for(int j=0;j<=i;j++){dp[i][j]+=max(dp[i+1][j],dp[i+1][j+1]);}}cout<<dp[0][0]; }
阅读全文
0 0
- 南阳oj The Triangle
- 南阳 18 The Triangle(dp)
- 北大OJ:The Triangle
- 南阳理工OJ_题目18 The Triangle
- 南阳理工acm 18 The Triangle
- 南阳oj(nyoj) 791 Color the fence
- 南阳 oj 语言入门 The Famous Clock
- 南阳oj 791 Color the fence
- 南阳OJ
- 南阳oj
- 南阳oj
- 南阳OJ
- 南阳理工oj_The Triangle
- 南阳oj 整数性质
- 复杂度 743 南阳oj
- 南阳 oj 147
- 01串---南阳OJ
- 南阳oj 字符串替换
- 手机页面
- java注意事项
- POJ 3461 Oulipo(KMP 一个串在另一个串出现的次数(可重叠|不可))
- 除留余数法实现哈希表,开vector法解决冲突
- Mysql报错:You must reset your password using ALTER USER statement before executing this statement.
- 南阳oj The Triangle
- 锁
- [Linux] 生成随机密码
- 递归专练C 经典汉诺塔问题
- 关于小白的我
- 第十五周LeetCode
- 2018第二届中国无人店大会 暨上海国际无人值守零售展览会
- mybatis 之 if test 条件
- 设计模式