其实就是简单递推对吧~

贴一发记忆化搜索的…

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

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

最新文章

  1. 搭建LNAMP环境(二)- 源码安装Nginx1.10
  2. [Java IO]02_字节流
  3. (ios) nsnotification总结
  4. 执行sudo时报错:effective uid is not 0
  5. Java引用机制——reference
  6. HDU 4417 (划分树+区间小于k统计)
  7. String对象的方法
  8. 《C标准库》——之&lt;stdarg.h&gt;
  9. Sqli-labs less 26a
  10. 有关Ant编译
  11. 利用linq快速判断给定数字是否包含在某个段范围内
  12. 001Spark文件分析测试
  13. hdu 4741 Save Labman No.004(2013杭州网络赛)
  14. Android学习之 AChartEngine 图表绘制
  15. jsp-2 简单的servlet连接mysql数据库 增删改查
  16. Python笔记&#183;第四章—— 细数Python中的数据类型以及他们的方法
  17. HTTP响应状态码含义参考
  18. Java小知识点总结
  19. 算法笔记--FFT
  20. Java如何处理已检查异常?

热门文章

  1. 一种排序(nyoj8)(简单排序)
  2. CodeForces 321A Ciel and Robot(数学模拟)
  3. [iOS]APP代码实践:建立一个辅助的APP类,降低对AppDelegate的改动
  4. SpringBoot学习之启动报错【This application has no explicit mapping for /error.....】
  5. MergeLinklist
  6. Django-配置celery
  7. BEGINNING SHAREPOINT&amp;#174; 2013 DEVELOPMENT 第8章节--配送SP2013Apps 应用程序生命周期
  8. 1987年国际C语言混乱代码大赛获奖的一行代码
  9. MVC程序部署后页面指向login.aspx
  10. iOS的基本框架