1.链接地址:

http://bailian.openjudge.cn/practice/1163

http://poj.org/problem?id=1163

2.题目:

总时间限制:
1000ms
内存限制:
65536kB
描述
7
3 8
8 1 0
2 7 4 4
4 5 2 6 5 (Figure 1)

Figure
1 shows a number triangle. Write a program that calculates the highest
sum of numbers passed on a route that starts at the top and ends
somewhere on the base. Each step can go either diagonally down to the
left or diagonally down to the right.

输入
Your program is to read from standard input. The first line
contains one integer N: the number of rows in the triangle. The
following N lines describe the data of the triangle. The number of rows
in the triangle is > 1 but <= 100. The numbers in the triangle,
all integers, are between 0 and 99.
输出
Your program is to write to standard output. The highest sum is written as an integer.
样例输入
5
7
3 8
8 1 0
2 7 4 4
4 5 2 6 5
样例输出
30
来源
IOI 1994

3.思路:

DP

4.代码:

 #include "stdio.h"
//#include "stdlib.h"
#define N 102
int a[N][N];
int main()
{
int count;
int i,j;
scanf("%d",&count);
for(i = ;i <count;i++)
{
for(j=;j<=i;j++)
{
scanf("%d",&a[i][j]);
}
}
for(i = count -;i>=;i--)
{
for(j=;j<=i;j++)
{
a[i][j] += ((a[i+][j]>a[i+][j+])?a[i+][j]:a[i+][j+]);
}
}
printf("%d",a[][]);
//system("pause");
return ;
}

OpenJudge/Poj 1163 The Triangle的更多相关文章

  1. POJ 1163 The Triangle(简单动态规划)

    http://poj.org/problem?id=1163 The Triangle Time Limit: 1000MS   Memory Limit: 10000K Total Submissi ...

  2. poj 1163 The Triangle &amp;poj 3176 Cow Bowling (dp)

    id=1163">链接:poj 1163 题意:输入一个n层的三角形.第i层有i个数,求从第1层到第n层的全部路线中.权值之和最大的路线. 规定:第i层的某个数仅仅能连线走到第i+1层 ...

  3. POJ 1163 The Triangle【dp+杨辉三角加强版(递归)】

    The Triangle Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 49955   Accepted: 30177 De ...

  4. POJ 1163 The Triangle 简单DP

    看题传送门门:http://poj.org/problem?id=1163 困死了....QAQ 普通做法,从下往上,可得状态转移方程为: dp[i][j]= a[i][j] + max (dp[i+ ...

  5. poj 1163 The Triangle

    The Triangle Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 43809   Accepted: 26430 De ...

  6. Poj 1163 The Triangle 之解题报告

    Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 42232   Accepted: 25527 Description 7 3 ...

  7. poj 1163 The Triangle 搜索 难度:0

    The Triangle Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 37931   Accepted: 22779 De ...

  8. POJ 1163 The Triangle DP题解

    寻找路径,动态规划法题解. 本题和Leetcode的triangle题目几乎相同一样的,本题要求的是找到最大路径和. 逆向思维.从底往上查找起就能够了. 由于从上往下能够扩展到非常多路径.而从下往上个 ...

  9. poj 1163 The Triangle 记忆化搜索

    The Triangle Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 44998   Accepted: 27175 De ...

随机推荐

  1. 软件测试之WEB测试经典总结

    在Web工程过程中,基于Web系统的测试.确认和验收是一项重要而富有挑战性的工作.基于Web的系统测试与传统的软件测试不同,它不但需要检查和验证是否按照设计的要求运行,而且还要测试系统在不同用户的浏览 ...

  2. XMPP——Smack[6]离线消息和离线文件的实现

    终篇,三天所学所用,也就这些,如果需要大家要自己去查资料研究研究,功能其实可以很强大的 可惜界面做得不好,一大短处,从大一迄今没整好,主要是个人审美不行,哎 毕业季呀毕业季,明天摆摊卖书,再半月就可能 ...

  3. MongoDB命令学习

    mongodb不像关系型数据库有很强大的GUI客户端,虽然mongodb也有,但功能和稳定性实在不敢恭维,所以操作mongodb我们大部分 都是用类似cmd命令的方式(mongodb称为shell操作 ...

  4. js 如何将无限级分类展示出来

    这个需要运用递归. 案例:将数据以 ul li ul li形式展现在div中. <div id="div"></div> 数据格式为json: var da ...

  5. HDU 1330 Nearest Common Ancestors(求两个点的近期公共祖先)

    题目链接:id=1330">传送门 在线算法: #include <iostream> #include <cstdio> #include <cstri ...

  6. Ubuntu Linux下如何配置Android开发环境

    下载和安装Win7系统Android开发环境中讲了怎样在Win7系统中安装Android开发环境,那么怎样在Linux系统中配置Android开发环境呢?本篇文章就将演示如何使用Eclipse.And ...

  7. Android ListView快速定位(四)

    方法四: 添加一个EditText,作为搜索框 + Filter 其实这个不算第四个方法,因为与第二个一样,主要是实现Filter. 但是对于EditText的监听,我以前也没有写过,所以也记录一下. ...

  8. ABAP 常用系统变量

    SY-ABCDE 常量,A-Z字母表SY-BATCH 后台的程序运行SY-COLNO:当前选定列的列号SY-CPAGE 列表的当前显示页SY-CUCOL 屏幕,PAI 的水平光标位置SY-CUROW: ...

  9. as3调用外部swf里的类的方法

    as3项目要调用外部swf里的类有3种方法: 1.将外部的swf发布为swc,使用时将swc引用添加到相应的项目中,这应该是最简单的一种引用.不过当项目中的类或组件比较多时就会使项目发布生成的swf文 ...

  10. 获取用户ip接口

    <script type="text/javascript" charset="gb2312" src="http://counter.sina ...