地址:http://poj.org/problem?id=3176

题目解析:没什么好说的,之前上课时老师讲过。从下往上找,每一个三角形的顶点可由两个角加上顶点的值 两种方式得到 ,用dp数组保存下最大值即可。

#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <queue>
#include <math.h>
#define N 400
#define inf 0x3f3f3f3f
typedef int ll;
using namespace std;
int a[N][N],dp[N][N];
int main()
{
int n;
while(scanf("%d",&n)!=EOF)
{
for(int i=; i<=n; i++)
{
for(int j=; j<=i; j++)
scanf("%d",&a[i][j]);
}
for(int i=; i<=n; i++)
{
dp[n][i]=a[n][i];
}
for(int i=n-; i>=; i--)
{
for(int j=; j<=i; j++)
{
dp[i][j]=max(a[i][j]+dp[i+][j],a[i][j]+dp[i+][j+]);
}
}
printf("%d\n",dp[][]);
}
return ;
}

最新文章

  1. Unix目录结构的来历
  2. vbox 虚拟机共享文件夹 debian
  3. php数据访问(修改)
  4. node.js 基础学习笔记3 -http
  5. BAT for循环
  6. 数32位 unsigned int中1的个数
  7. 关于Filezilla是否支持sftp
  8. HDU 1247 Hat’s Words
  9. 我所经历的SAP选型
  10. (一)初识Android
  11. 模拟google分页效果
  12. hdoj 1054 Strategic Game【匈牙利算法+最小顶点覆盖】
  13. Ftp不能登陆的解决方法
  14. The JSR-133 Cookbook for Compiler Writers(an unofficial guide to implementing the new JMM)
  15. [个人小工具]清除SVN控制
  16. ArcGIS 网络分析[1.5] 使用点线数据一起创建网络数据集(如何避免孤立点/点与线的连通性组合结果表)
  17. csv文件读写处理
  18. 【输入法】Rime-中州韵 基本设置 附:官方定制指南
  19. serv-U使用
  20. linux shell中&#39;&#39;,&quot;&quot;和``的区别

热门文章

  1. 【转】H5页面的测试点总结
  2. web页面防盗链功能使用--request.getHeader(&quot;Referer&quot;)
  3. 第二百六十五节,xss脚本攻击介绍
  4. Github+Jekyll —— 创建个人免费博客(五)jekyllproject公布到github上
  5. Spring_day01--Spring的bean管理(xml方式)_属性注入介绍
  6. Struts2_day03--课程安排_OGNL概述入门_什么是值栈_获取值栈对象_值栈内部结构
  7. Effective C++ Item 9 Never call virtual functions during constrution or destruction
  8. Sokect异步连接发送
  9. 利用hugo生成静态站点
  10. tomcat 权限问题