最简单的DP问题(POJ1163)
来源:互联网 发布:淘宝美工主页设计 编辑:程序博客网 时间:2024/04/29 19:08
对动态规划一直很抵触,希望通过这道题能够逐渐学好这一算法。
题目连接:点击打开链接
转换思维,不是从顶部往下走,而是从底部往上推,不断的缩小问题的规模。
代码如下:
#include <stdio.h>#include <stdlib.h>#define max(x,y) (x>y?x:y)int a[110][110];int main(){ int i, j, n; //freopen("a.txt", "r", stdin); while(scanf("%d", &n)!=EOF){ for(i=0; i<n; i++){ for(j=0; j<=i; j++){ scanf("%d",&a[i][j]); } } for(i=n-1; i>=0; i--){ for(j=0; j<=i; j++){ a[i][j] += max(a[i+1][j],a[i+1][j+1]); } } printf("%d\n", a[0][0]); } return 0;}
- 最简单的DP问题(POJ1163)
- poj1163 简单的dp
- poj1163 简单DP
- POJ1163 The Triangle简单dp
- poj1163——The Triangle(简单dp)
- poj1163(DP)and3176(DP)多串的…
- 最简单的dp问题(1)——hdu2602
- POJ1163 The Triangle DP简单题
- poj1163 dp
- DP入门题--数塔问题(poj1163)
- 最简单的DP问题2——hdu1114
- 最简单的DP问题3——hdu2191
- C++ 求矩阵最短路问题最简单最暴力的dp解法
- poj1163 dp水题
- poj1163 递归或dp
- POJ1163 The Triangle 【DP】
- poj1163 dp the triangle
- DP 数字三角形(POJ1163)
- spi flash 驱动
- AJAX 跨域调用 快递查询API接口
- 3.关于版本号基础知识
- Linux split 和 cat详解
- linux中文问题
- 最简单的DP问题(POJ1163)
- 准确生成电信、联通、移动IP地址段
- 11级_Java_曹建波4.11 接口
- 黑马程序员--FileStream文件操作
- 关于CDialogBar的编程
- SRM540-div1-1-div2-2-ImportantSequence
- 如何将精彩回帖置顶--实现"亮了的回帖"
- Linux 获取其他程序返回值
- MySQL中的describe关键字