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. linux快速入门 1.1命令行操作

    http://lovesoo.org/linux-command-line-operation.html 1.1命令行操作 目录: <wp_nokeywordlink>Shell简介 &l ...

  2. CentOS 6.5 下载地址

    CentOS 6.5 主要改动 Precision Time Protocol(精确时间协议)—— 原先是项技术预览 —— 现在已获全面支持.以下驱动程序支持网络时间戳印:bnx2x.tg3.e100 ...

  3. 淘宝IP地址查询

    官方网址:http://ip.taobao.com/index.php 相关文章: http://www.cnblogs.com/zetee/p/3482085.html http://www.cnb ...

  4. 如何调试libc++abi.dylib handler threw exception错误

    From:http://blog.csdn.net/naruto_ku/article/details/8779203 在进行iOS开发时,偶尔会碰到libc++abi.dylib handler t ...

  5. UvaLive 6667 Longest Chain (分治求三元组LIS&amp;树状数组)

    题目链接: here 题意: 和hdu4742类似.差别就是一部分三元组是直接给出的.另一部分是用他给的那个函数生成的.还有就是这里的大于是严格的大于a>b必须ax>bx,ay>by ...

  6. [Open Projects Series] ViewPagerTransforms

    https://github.com/jfeinstein10/JazzyViewPager https://github.com/ToxicBakery/ViewPagerTransforms

  7. 【BZOJ2318】【spoj4060】game with probability Problem 概率DP

    链接: #include <stdio.h> int main() { puts("转载请注明出处[辗转山河弋流歌 by 空灰冰魂]谢谢"); puts("网 ...

  8. SAP交货单过账自动生产采购订单、采购订单自动收货入库

    公司间需要买卖操作,由于发货和收货都是同一批人在操作,为了减少业务人员的工作量,提高工作效率,特实现以上功能 1.增强实现:增强点为交货单过账成功时触发,在提交前触发,如果遇到不可预知问题,可能造成数 ...

  9. 文件I/O(不带缓冲)之close函数

    可调用close函数关闭一个打开的文件: #include <unistd.h> int close( int filedes ); 返回值:若成功则返回0,若出错则返回-1. 关闭一个文 ...

  10. Android_listView_Listener

    layout.xml <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" x ...