其实就是简单递推对吧~

贴一发记忆化搜索的…

#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 0x3f3f3f3f
const 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…算了…

给个传送门,做个稍微难的(加个路径输出),题目是一样的。

poj3176【简单DP】的更多相关文章

  1. HDU 1087 简单dp,求递增子序列使和最大

    Super Jumping! Jumping! Jumping! Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 ...

  2. Codeforces Round #260 (Div. 1) A. Boredom (简单dp)

    题目链接:http://codeforces.com/problemset/problem/455/A 给你n个数,要是其中取一个大小为x的数,那x+1和x-1都不能取了,问你最后取完最大的和是多少. ...

  3. codeforces Gym 100500H A. Potion of Immortality 简单DP

    Problem H. ICPC QuestTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100500/a ...

  4. 简单dp --- HDU1248寒冰王座

    题目链接 这道题也是简单dp里面的一种经典类型,递推式就是dp[i] = min(dp[i-150], dp[i-200], dp[i-350]) 代码如下: #include<iostream ...

  5. poj2385 简单DP

    J - 简单dp Crawling in process... Crawling failed Time Limit:1000MS     Memory Limit:65536KB     64bit ...

  6. hdu1087 简单DP

    I - 简单dp 例题扩展 Crawling in process... Crawling failed Time Limit:1000MS     Memory Limit:32768KB     ...

  7. poj 1157 LITTLE SHOP_简单dp

    题意:给你n种花,m个盆,花盆是有顺序的,每种花只能插一个花盘i,下一种花的只能插i<j的花盘,现在给出价值,求最大价值 简单dp #include <iostream> #incl ...

  8. hdu 2471 简单DP

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2571 简单dp, dp[n][m] +=(  dp[n-1][m],dp[n][m-1],d[i][k ...

  9. Codeforces 41D Pawn 简单dp

    题目链接:点击打开链接 给定n*m 的矩阵 常数k 以下一个n*m的矩阵,每一个位置由 0-9的一个整数表示 问: 从最后一行開始向上走到第一行使得路径上的和 % (k+1) == 0 每一个格子仅仅 ...

  10. poj1189 简单dp

    http://poj.org/problem?id=1189 Description 有一个三角形木板,竖直立放.上面钉着n(n+1)/2颗钉子,还有(n+1)个格子(当n=5时如图1).每颗钉子和周 ...

随机推荐

  1. SolidEdge如何绘制变化半径倒圆角

    1 在要变化半径的边上打一些点   2 点击倒角命令的参数对话框,选择可变半径   3 选择倒角的直线,右击确认,再依次点击关键点,修改倒角数值,修改之后按回车,继续下一个点,直到结束.  

  2. 关于 redux-saga 中 take 使用方法详解

    本文介绍了关于redux-saga中take使用方法详解,分享给大家,具体如下: 带来一个自己研究好久的API使用方法. redux-saga中effect中take这个API使用方式,用的多的是ca ...

  3. 自己动手写CPU之第九阶段(4)——载入存储指令实现思路

    将陆续上传新书<自己动手写CPU>,今天是第40篇,我尽量每周四篇,可是近期已经非常久没有实现这个目标了,一直都有事,不好意思哈. 开展晒书评送书活动,在q=%E4%BA%9A%E9%A9 ...

  4. nc和telnet配合使用

    nc -l 9932 -c  用nc监听9932端口 telnet 180.150.184.115 29933  telnet 29932 端口

  5. HDU2084_数塔【简单题】【数塔】

    数塔 Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submiss ...

  6. 2016-1-8 windows 7下安装mysql及其配置和运用

    绪言 最近学习了一下mysql的相关用法,以及vs2010结合mysql的使用. 遇到的问题:1.安装mysql 5.6 绿色免安装版本,出现mysql server not connect loca ...

  7. 基于bootstrap_博客页面

    <!DOCTYPE html> <!-- saved from url=(0036)http://v3.bootcss.com/examples/blog/ --> <h ...

  8. error at ::0 can&#39;t find referenced pointcut pointCutName 错误解决方法

    Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire method: publi ...

  9. openwrt - squashfs-sysupgrade.bin 的生成过程

    squashfs-sysupgrade.bin 生成过程图 路径变量 $(KERNEL_BUILD_DIR)="/home/sam/Projects/openwrt-mt7620n/buil ...

  10. Robots协议应用与写法研究