poj 1168 The Triangle
| Time Limit: 1000MS | Memory Limit: 10000K | |
| Total Submissions: 39169 | Accepted: 23518 | 
Description
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.
Input
Output
Sample Input
5
7
3 8
8 1 0
2 7 4 4
4 5 2 6 5
Sample Output
30
Source
#include<cstdio>
#include<cmath>
#include<cstring>
#include<iostream>
using namespace std;
int map[][];
int main(){
int n,i,j;
cin>>n;
for(i=;i<n;i++){
for(j=;j<=i;j++){
scanf("%d",&map[i][j]);
}
}
for(i=n-;i>=;i--){
for(j=;j<=i;j++){
map[i][j]+=map[i+][j]>map[i+][j+]?map[i+][j]:map[i+][j+];
}
}
cout<<map[][]<<endl;
return ;
}
poj 1168 The Triangle的更多相关文章
- POJ 1163 The Triangle(简单动态规划)
		
http://poj.org/problem?id=1163 The Triangle Time Limit: 1000MS Memory Limit: 10000K Total Submissi ...
 - 【POJ】2954 Triangle(pick定理)
		
http://poj.org/problem?id=2954 表示我交了20+次... 为什么呢?因为多组数据我是这样判断的:da=sum{a[i].x+a[i].y},然后!da就表示没有数据了QA ...
 - OpenJudge/Poj 1163 The Triangle
		
1.链接地址: http://bailian.openjudge.cn/practice/1163 http://poj.org/problem?id=1163 2.题目: 总时间限制: 1000ms ...
 - POJ 1163 The Triangle【dp+杨辉三角加强版(递归)】
		
The Triangle Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 49955 Accepted: 30177 De ...
 - 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 ...
 - poj 1163 The Triangle 搜索 难度:0
		
The Triangle Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 37931 Accepted: 22779 De ...
 - POJ 1163 The Triangle DP题解
		
寻找路径,动态规划法题解. 本题和Leetcode的triangle题目几乎相同一样的,本题要求的是找到最大路径和. 逆向思维.从底往上查找起就能够了. 由于从上往下能够扩展到非常多路径.而从下往上个 ...
 - POJ 2986 A Triangle and a Circle(三角形和圆形求交)
		
Description Given one triangle and one circle in the plane. Your task is to calculate the common are ...
 
随机推荐
- Linq转换操作之ToArray,ToList,ToDictionary源码分析
			
Linq转换操作之ToArray,ToList,ToDictionary源码分析 一:linq中的转换运算符 1. ToArray 我们经常用在linq查询上吧. linq只能运用在IEnumerab ...
 - arcgis android 10.2.5开发环境配置
			
android里要添加arcgis android 的支持,其实本质是添加了jar包,so库,清单文件里申请了权限而已. 插件是为了方便创建arcgis android工程,然后并没有什么卵用. ar ...
 - EF修改model自动更新数据库
			
最近用MVC+EF学习时遇到修改model后而数据库没更新报错,就在网上找关于数据迁移自动更新数据库的,折腾了大半天终于弄了出来 第一步:在程序包管理器控制台里: Enable-Migrations ...
 - RabbitMQ与.net core(四) 消息的优先级 与 死信队列
			
1.消息的优先级 假如现在有个需求,我们需要让一些优先级最高的通知推送到客户端,我们可以使用redis的sortedset,也可以使用我们今天要说的rabbit的消息优先级属性 Producer代码 ...
 - Visual Studio 2015 Update 2 发布
			
2016年3月30日,微软发布了Visual Studio 2015 Update 2 . 更新内容: Visual Studio Visual Studio Tools for Apache Co ...
 - mongodb driver2.5环境注意事项
			
mongodb driver2.5环境注意事项 一.问题: 如果使用vs2012开发就会报这个错误: 未能加载文件或程序集“System.Runtime.InteropServices.Runtime ...
 - NetEaseGame/ATX 的MD
			
# ATX(AutomatorX) (中文版)[](ht ...
 - [Android] Android  MVP 架构下  最简单的 代码实现
			
Android MVP 架构下 最简单的 代码实现 首先看图: 上图是MVP,下图是MVC MVP和MVC的区别,在于以前的View层不仅要和model层交互,还要和controller层交互.而 ...
 - Linux环境下动态链接库的生成和使用
			
使用自己封装的so时遇到了点问题,本着简便原则决定写个demo看看,顺便记录下整个过程. 1)生成so所需的文件如下: print.h #ifndef __print_h__ #define __pr ...
 - python difflib详解
			
difflib -帮助进行差异化比较 这个模块提供的类和方法用来进行差异化比较,它能够生成文本或者html格式的差异化比较结果,如果需要比较目录的不同,可以使用filecmp模块. class dif ...