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. cocos2d-x中本地推送消息

    作者:HU 转载请注明,原文链接:http://www.cnblogs.com/xioapingguo/p/4038277.html  IOS下很简单: 添加一条推送 void PushNotific ...

  2. The maximum number of cell styles was exceeded. You can define up to 4000 styles

    POI操作Excel中,导出的数据不是很大时,则不会有问题,而数据很多或者比较多时, 就会报以下的错误,是由于cell styles太多create造成,故一般可以把cellstyle设置放到循环外面 ...

  3. Android 百度地图API 定位 导航

    看看这个利用百度地图定位并实现目的地导航的Demo. 首先看实现效果:                          进 入后首先会得到当前位置,在地图上显示出来.在输入框中输入目的地后,就会在地 ...

  4. XML文件

    XML 指可扩展标记语言(eXtensible Markup Language) XML 被设计用来传输和存储数据. 什么是 XML? XML 指可扩展标记语言 XML 是一种标记语言,非常类似 HT ...

  5. SharePoint 2013+ Sqlserver 2014 Kerberos 配置传奇, 最终的解决方案 验证。

    SharePoint 2013+ Sqlserver 2014 Kerberos 配置传奇. 1,安装数据库,我就不多说安装,客户一定要注意. 我将参照以下实施例和账户. 2,建立DNS,假设没有DN ...

  6. C++ stringstream介绍,使用方法与例子

    From: http://www.usidcbbs.com/read-htm-tid-1898.html C++引入了ostringstream.istringstream.stringstream这 ...

  7. sql根据表名获取字段及对应说明

    SELECT TableName = OBJECT_NAME(c.object_id), ColumnsName = c.name, Description = ex.value, ColumnTyp ...

  8. 从Eclipse里导出Android程序到手机里

    参考自:http://wenku.baidu.com/view/e28bb57c1711cc7931b716a7.html

  9. APP运营干货分享

    从移动互联网市场总监岗位出发,从几个方面来阐述移动互联网部门如何制定一份运营推广策划案,至于关于移动互联网,移动电商是大趋势这些虚的.空泛的文字,不展开说了. 一.竞品分析 1.选择竞品,做好定位(选 ...

  10. stitching detail输出的dot图含义

    如果利用opencv里面提供的stitching detail的话. 输入参数: stitching_detail --save_graph a.dot 1.png 2.png 其中a.dot 文件中 ...