poj3176【简单DP】
来源:互联网 发布:linux rc5.d 编辑:程序博客网 时间:2024/06/06 19:05
其实就是简单递推对吧~
贴一发记忆化搜索的…
#include <iostream>#include <stdio.h>#include <string.h>#include <stack>#include <queue>#include <map>#include <set>#include <vector>#include <math.h>#include <algorithm>using namespace std;#define LL long long#define INF 0x3f3f3f3fconst double pi = acos(-1.0);const int mod = 1e9+7;const int N =355;int a[N][N];int dp[N][N];int n;int dfs(int x,int y){ if(dp[x][y]!=-1) return dp[x][y]; if(x==n) return dp[x][y]=a[x][y]; int temp=0; if(x+1<=n) temp=max(temp,max(dfs(x+1,y),dfs(x+1,y+1))); return dp[x][y]=temp+a[x][y];}int main(){ scanf("%d",&n); for(int i=1;i<=n;i++) for(int j=1;j<=i;j++) scanf("%d",&a[i][j]); memset(dp,-1,sizeof(dp)); printf("%d\n",dfs(1,1)); return 0;}
再贴一发递推的…………e…算了…
给个传送门,做个稍微难的(加个路径输出),题目是一样的。
0 0
- poj3176 简单dp
- POJ3176 简单DP....
- poj3176【简单DP】
- POJ3176-Cow Bowling-简单dp
- (POJ3176) Cow Bowling <简单dp>
- poj3176 dp
- poj3176(DP)
- POJ3176(DP)
- poj3176 Cow Bowling DP
- POJ3176 DP 数塔
- [dp]poj3176 Cow Bowling
- poj3176 dp 数字三角形
- POJ3176 DP水题
- [DP]poj3176 Cow Bowling
- POJ3176-Cow Bowling(dp)
- poj3176
- poj3176
- poj3176
- 半分钟内能看透问题本质的人是如何思考的?
- orbslam2-基础理论(六)-g2o(常用的优化算法)
- C# 获得上级目录路劲
- 设置RadioGroup下所有radioButton均不可点击
- linux驱动模型开发——linux platform总线机制讲解与实例开发
- poj3176【简单DP】
- 【POJ 3461】 Oulipo(KMP)
- Tomcat设置内存
- 数塔
- iOS 报错:objc[1334]: Class X ... One of the two will be used. Which one is undefined
- 【HDU】-1176-免费馅饼(DP,好)
- 整洁代码-----有意义的命名
- 分布式队列编程模型
- Android 读取<meta-data>元素的数据