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 ...
随机推荐
- CSS与jQuery补漏
1.position属性 这个属性定义建立元素布局所用的定位机制.任何元素都可以定位,不过绝对或固定元素会生成一个块级框,而不论该元素本身是什么类型.相对定位元素会相对于它在正常流中的默认位置偏移. ...
- scvmm2008 错误 2921 0x8007054F
这个错误是由于bits智能传输服务依赖的https 443端口被占用.443端口一般常用于银行.购物网站,是一种加密的http,一般是通过ssl安全套接字来加密的,但是ssl漏洞可能被木马病毒利用. ...
- Ocelot Consul ACL
Ocelot允许您指定服务发现提供程序,并使用它来查找Ocelot正在将请求转发给下游服务的主机和端口.目前,这仅在GlobalConfiguration部分中受支持,这意味着所有ReRoute将使用 ...
- Spring各个jar包详解
Spring各jar包详解 spring.jar 是包含有完整发布模块的单个jar 包.但是不包括mock.jar,aspects.jar, spring-portlet.jar, and sprin ...
- BOI2007 Mokia | cdq分治求二维点数模板
题目链接:戳我 也没什么,其实主要就是为了存一个求二维坐标上矩形内点的个数的模板.为了之后咕咕咕地复习使用 不过需要注意的一点是,树状数组传x的时候可千万不要传0了!要不然会一直死循环的...qwqw ...
- Mysql内置功能《六》流程控制
一 流程控制 delimiter // CREATE PROCEDURE proc_if () BEGIN declare i int default 0; if i = 1 THEN SELECT ...
- 比较旧的写法:验证车牌、手机号、电话、qq等
1.验证车牌代码: <!DOCTYPE html> <html lang="en"> <head> <meta charset=" ...
- CentOS安装搭建zookeeper
原文连接:https://www.cnblogs.com/rwxwsblog/p/5806075.html zookeeper集群搭建(三台) 注意关闭机器防火墙! 配置ip别名:编辑文件 # /e ...
- HTML-基础及一般标签
HTML 内容 Hyper Text Markup Language 超文本标记语言(包含文本.表格.图片.声音.视频等,同时也是文档) HTML 元素指的是从开始标签(start t ...
- dcoker做私有仓库
在官网上拉取私有仓库的镜像.(官网提供的镜像为:registry) docker pull registry 启动镜像,并且映射端口.(启动时加-p参数即可) docker -d -p 5000 ...