POJ 1163 最佳路径简单DP
2013-08-28 11:19
295 查看
思路:找出最佳路径,使其和值最大,逆向找出最大值,往前推比较简单。此题较为容易,动态规划的简单的题。
代码如下:
代码如下:
#include <iostream> #include <map> #include <string> #include <cstring> #include <cstdio> #include <cmath> #include <algorithm> using namespace std; int a[101][101]; int main() { int i,j,n; cin >> n; for(i=0; i<n; i++) for(j=0; j<=i; j++) cin >> a[i][j]; for(i=n-2; i>=0; i--) for(j=0; j<i+1; j++) a[i][j]+=max(a[i+1][j],a[i+1][j+1]); //动态规划 cout<<a[0][0]<<endl; return 0; }
相关文章推荐
- poj 1163/3176 数字三角形【简单DP】
- DP 简单题 之 poj 1163
- POJ 1163 The Triangle (简单DP)
- dp问题最佳路径的构建 poj 1015
- DP 简单题 之 poj 1163
- poj 2353(简单dp+输出路径)
- DP-POJ 1163 Triangle(简单数字三角形)
- poj1163 简单DP
- POJ 3176-Cow Bowling/POJ 1163-The Triangle(简单DP-数塔)
- poj1163——The Triangle(简单dp)
- POJ 1163 The Triangle (简单线性dp)
- POJ 1163 The Triangle 简单DP
- POJ 1163 The Triangle 简单DP
- POJ 2111 DP+记录路径
- poj 1655 简单树形dp
- poj 2193 Lenny's Lucky Lotto Lists 简单dp
- POJ 1163 The Triangle(数塔模型dp)
- poj 1163 The Triangle(第一道DP~~~~)
- POJ 3373 Changing Digits(记录路径的dp)
- 【POJ 3162】 Walking Race (树形DP-求树上最长路径问题,+单调队列)