POJ 1163 The Triangle(简单动态规划)
http://poj.org/problem?id=1163
The Triangle
Description 7 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. Input 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.
Output Your program is to write to standard output. The highest sum is written as an integer.
Sample Input 5 Sample Output 30 Source |
[Submit] [Go Back] [Status] [Discuss]
简单的动态规划。。。
#include<stdio.h>
int main() { int a[][]; int n,i,j; scanf("%d",&n); for(i=;i<n;i++) for(j=;j<=i;j++) scanf("%d",&a[i][j]); for(i=n-;i>=;i--) for(j=;j<=i;j++) a[i][j]+=(a[i+][j]>a[i+][j+])?a[i+][j]:a[i+][j+]; printf("%d\n",a[][]); return ; } |
POJ 1163 The Triangle(简单动态规划)的更多相关文章
- POJ 1163 The Triangle 简单DP
看题传送门门:http://poj.org/problem?id=1163 困死了....QAQ 普通做法,从下往上,可得状态转移方程为: dp[i][j]= a[i][j] + max (dp[i+ ...
- POJ - 1163 The Triangle 【动态规划】
一.题目 The Triangle 二.分析 动态规划入门题. 状态转移方程$$DP[i][j] = A[i][j] + max(DP[i-1][j], DP[i][j])$$ 三.AC代码 1 #i ...
- poj 1163 The Triangle &poj 3176 Cow Bowling (dp)
id=1163">链接:poj 1163 题意:输入一个n层的三角形.第i层有i个数,求从第1层到第n层的全部路线中.权值之和最大的路线. 规定:第i层的某个数仅仅能连线走到第i+1层 ...
- POJ 1163 The Triangle【dp+杨辉三角加强版(递归)】
The Triangle Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 49955 Accepted: 30177 De ...
- OpenJudge/Poj 1163 The Triangle
1.链接地址: http://bailian.openjudge.cn/practice/1163 http://poj.org/problem?id=1163 2.题目: 总时间限制: 1000ms ...
- POJ 1163 The Triangle(经典问题教你彻底理解动归思想)
The Triangle Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 38195 Accepted: 22946 De ...
- The Triangle (简单动态规划)
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 calc ...
- poj 1163 The Triangle
The Triangle Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 43809 Accepted: 26430 De ...
- Poj 1163 The Triangle 之解题报告
Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 42232 Accepted: 25527 Description 7 3 ...
随机推荐
- Feature Access
在ArcGIS Server中发布支持Feature Access地图服务,你需要知道的几点: 所绘制的mxd地图文件中包含的数据,必须来自企业级数据库链接: mxd中包含的所有图层的数据,必须来自同 ...
- 【转载】Shell判断字符串包含关系的几种方法
http://www.cnblogs.com/ginsonwang/p/5525340.html 下面是直接copy的内容: (本来是不打算copy的,但是每次用到或看的时候都要跳转,感觉挺麻烦的.就 ...
- vue2.0 组件之间的数据传递
组件间的数据传递// 父组件<template><div class="order"><dialog-addpro v-on:closedialog= ...
- hbase 的体系结构
hbase的服务体系遵从的是主从结构,由HRegion(服务器)-HRegionServer(服务器集群)-HMaster(主服务器)构成, 从图中能看出多个HRegion 组成一个HRegionSe ...
- 使用Json Web Token设计Passport系统
>>Token Auth机制 基于Token的身份验证是无状态的,我们不将用户信息存在服务器或Session中. 相比原始的Cookie+Session方式,更适合分布式系统的用户认证,绕 ...
- Microsoft Visual Studio 文件识别及其用途简述
Microsoft Visual Studio IDE开发工具集,目前已推出多个不同版本,从之前的VC4.0到现在的VS2015,各个版本都会或多或少的功能或性能上的修改.提升,具体的改进地方可去官网 ...
- Kafka基本原理
简介 Apache Kafka是分布式发布-订阅消息系统.它最初由LinkedIn公司开发,之后成为Apache项目的一部分.Kafka是一种快速.可扩展的.设计内在就是分布式的,分区的和可复制的提交 ...
- ORA-12541:TNS没有监听器
cmd---services.msc----以Oracle开头TNListener结尾的服务启动它 如果还没有启动,修改注册表,Win+r,输入regedit回车,找到HKEY_LOCAL_MACHI ...
- PowerDesigner修改生成mysql视图
今天遇到了个问题,就是有PowerDesigner的设计图,能生成oracle的视图,不能生成mysql,在网上找到了解决方案, 非常感谢各位网友的分享,这个不是抄袭,主要是为了让更多的人知道这种解决 ...
- linux 负载均衡
[博文推荐]关于负载均衡技术使用的一些误区 如今,负载均衡已经不是一个新鲜的词,也不是什么新技术,主要用于解决单机负载能力的局限性,但问题是你的应用真的到了单 机的负载上限了吗,未必,很多不知道如何推 ...