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 ...
随机推荐
- selenium webdriver 建行软键盘输入密码
driver.get("https://ibsbjstar.ccb.com.cn/app/V5/CN/STY1/login.jsp"); driver.manage().timeo ...
- Python3.5在Windows 7下连接ORACLE数据库
1.首先需要安装好oracle数据库,本机适用plsql连接数据库正常,记录下数据库名称 2.安装cx_oracle模块 pip install cx_Oracle 3.python中引入模块 imp ...
- 【webGL】threejs常用的api
/*** 场景(scene) ***/ var scene = new THREE.Scene(); // 创建场景 scene.add(x); // 插入场景 /*** 相机(camera) *** ...
- EF操作多数据库
1.Account3_Register_DB_Model作为(空)模板库,根据此模板生成的其他数据除了数据库名称不一样,其他表,视图,字段等等都一致 2.Account3_Platform_Maste ...
- [Java 8] (10) 使用Lambda完成函数组合,Map-Reduce以及并行化
好文推荐!!!!! 原文见:http://blog.csdn.net/dm_vincent/article/details/40856569 Java 8中同时存在面向对象编程(OOP)和函数式编程( ...
- Toad for Sqlserver
# 设置制表符 从sqlserver拷贝的存储过程粘贴到Toad,代码变得不整齐了,这就需要设置下制表符的大小.
- 谷歌浏览器对uploadify(swf)上传控件 崩溃问题
页面加上 <script type="text/javascript" src=@Url.Content("~/Content/js/jquery.uploadif ...
- ZooKeeper基本原理
ZooKeeper简介 ZooKeeper是一个开放源码的分布式应用程序协调服务,它包含一个简单的原语集,分布式应用程序可以基于它实现同步服务,配置维护和命名服务等. ZooKeeper设计目的 1. ...
- 配置mongoDB服务
上一节说到mongoDB的环境搭建,但是那种方法启动mongoDB太繁琐了. 今天先说说简化mongoDB启动的配置. 首先在命令行中运行的”C:\Program Files\MongoDB 2.6 ...
- Nginx+FastCGI运行原理
Nginx不支持对外部程序的直接调用或者解析,所有的外部程序(包括PHP)必须通过FastCGI接口来调用.FastCGI接口在Linux下是socket(这个socket可以是文件socket,也可 ...


