POJ - 1163 The Triangle
来源:互联网 发布:污水处理厂模拟软件 编辑:程序博客网 时间:2024/06/05 02:59
The Triangle
Time Limit: 1000MS Memory Limit: 10000KB 64bit IO Format: %I64d & %I64u
Description
73 88 1 02 7 4 44 5 2 6 5(Figure 1)
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
573 88 1 0 2 7 4 44 5 2 6 5
Sample Output
30
#include<iostream>#include<algorithm>using namespace std;int main(){int n;int a[110][110];cin >> n;for (int i = 0; i < n;i++)for (int j = 0; j <= i; j++)cin >> a[i][j];for (int i = n - 2; i >= 0;i--)for (int j = 0; j <= i; j++)a[i][j] = a[i][j]+max(a[i + 1][j], a[i + 1][j + 1]);cout << a[0][0] << endl;}
0 0
- The Triangle--poj--1163
- POJ 1163 The Triangle
- poj 1163 The Triangle
- Poj 1163 The Triangle
- poj 1163 The Triangle
- poj 1163 The Triangle
- poj 1163 The Triangle
- POJ 1163 The Triangle
- poj 1163 The Triangle
- POJ 1163 The Triangle
- POJ 1163 The Triangle
- poj 1163 The Triangle
- poj-1163 The Triangle
- poj 1163 The Triangle
- POJ-1163-The Triangle
- poj 1163 The Triangle
- POJ-1163-The Triangle
- poj 1163 The Triangle
- Labview图像处理-2处理方法
- android之资源优化处理---图片压缩
- 黑马程序员——JAVA学习笔记(五)
- VMware中Ubuntu14.04下Spark虚拟集群安装运行步骤简述
- 嵌入式常见经典笔试题
- POJ - 1163 The Triangle
- 2015阿里实习内推三面+HR面
- 推荐系统的坑
- winwebmail设置能用foxmail收发邮件
- VI中的多行删除与复制及其他常用命令
- 实战:供应链如何应用大数据
- xrandr --output HDMI2 --mode 1366x768 --right-of VGA1
- div高度随窗口变化而变化
- 第三周 项目一(4):三角形类的构造函数(使用参数初始化表)