poj 3176 dp
来源:互联网 发布:张国荣告别演唱会知乎 编辑:程序博客网 时间:2024/05/17 09:31
poj 3176 dp
戳这原题
大致题意:给你个数字金字塔,每个点带权值,每个点只可以选上一行相邻的2个点【表述就是这么个意思】,问最长路径值啊
思路:
of course dp。
这题写的还算顺手啊。事实证明,题是刷熟练的orz。
dp[i][j]表示最长路径,从下往上刷,所以方程:
dp[i][j]=map[i][j]+max(dp[i+1][j],dp[i+1][j+1]);
啦啦啦
#include<cstdio>#include<algorithm>#define maxn 351using namespace std;int map[maxn][maxn];int dp[maxn][maxn];int n;int i,j,k;int main(){ scanf("%d",&n); for(i=1;i<=n;i++) { for(j=1;j<=i;j++) { scanf("%d",&map[i][j]); if(i == n) dp[i][j]=map[i][j]; } } for(i=n-1;i>=1;i--) { for(j=1;j<=i;j++) { dp[i][j]=map[i][j]+max(dp[i+1][j],dp[i+1][j+1]); } } printf("%d",dp[1][1]); return 0;}
1 0
- poj 1163&3176 DP
- POJ 3176 简单DP
- poj 3176 dp
- POJ 3176 简单DP
- POJ 3176 Cow Bowling DP
- poj-3176-Cow Bowling-dp
- poj 3176 Cow Bowling (DP)
- poj 3176 Cow Bowling dp
- POJ 3176 Cow Bowling DP
- poj 3176Cow Bowling DP
- POJ 3176 : Triangle - 水DP
- Poj 3176 Cow Bowling【dp】
- poj 3176 (dp 金字塔)
- POJ 3176 Cow Bowling (dp)
- POJ 3176 (简单dp)
- poj dp
- 【dp】POJ
- 【dp】POJ
- C# 并发容器之ConcurrentDictionary与普通Dictionary带锁的性能对比
- 推荐开发工具系列之--Cygwin
- hdu4821 string (字符串Hash)
- Thinking In Java 之 How a garbage collector works
- iOS UILabel 用法常用属性
- poj 3176 dp
- 未使用的局部变量
- struts1学习笔记
- 编译原理初探
- UML之宏观概述
- QuickFix/J (3):自定义字段
- Android 实战面试题分享
- Android拖拽和缩放
- K均值聚类算法的MATLAB实现