HDU2084(DP)
来源:互联网 发布:学生男鞋品牌 知乎 编辑:程序博客网 时间:2024/05/21 08:54
每次找相邻的点的中的max,计入dp中就可以了
#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>#include <map>#include <stack>#include <queue>#include <list>#include <cmath>using namespace std;#define cir(a,b) memset(a,b,sizeof a)typedef long long LL;const int maxn = 10000+10;const int INF = 1e9+10;int T;int n;int s[100+10][100+10];int dp[105][105];int main(){ cin >> T; while(T--) { cin >> n; for(int i=1; i<=n; i++) { for(int j=1; j<=i; j++) { cin >> s[i][j]; } } for(int i=1; i<=n; i++) dp[n][i] = s[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]+ s[i][j],dp[i+1][j+1]+ s[i][j]) ; // cout << dp[i][j] <<" "; } //cout << endl; } cout << dp[1][1] << endl; }}
阅读全文
0 0
- HDU2084(DP)
- DP--hdu2084树塔
- hdu2084 dp数塔
- HDU2084:数塔(DP)
- HDU2084(最大和DP)
- 【DP】HDU2084数塔
- dp-数塔(hdu2084)
- hdu2084 数塔 DP
- hdu2084 DP入门
- hdu2084 数塔【简单DP】
- hdu2084 - 数塔 (经典dp)
- HDU2084 数塔 【DP问题】
- hdu2084数塔(DP)
- HDU2084 数塔 DP水题
- hdu2084 数塔 (DP)
- HDU2084基础DP数塔
- HDU2084(数字三角dp)
- HDU2084
- android sparseArray源码解析,比较hashmap
- 前端魔法堂:屏蔽Backspace导致页面回退
- mybatis 专场(未完待续...)
- python转换目录
- 安利jqueryForm:让文件上传更轻松
- HDU2084(DP)
- SCALA学习笔记
- LazyViewPager 实现ViewPager懒加载的三种方法
- Mysql更改root密码
- mysql 安装详细步骤
- 【PMP】学习笔记 三点估算法 挣值管理 折旧法 沟通渠道计算
- Butter Knife,SwipeRefreshLayout
- Linux下端口管理
- 分布式系统常见的事务处理机制