POJ 1163The Triangle
来源:互联网 发布:软件服务外包专业 编辑:程序博客网 时间:2024/06/08 16:27
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
简单dp
#include<cstdio>#include<cstring>#include<algorithm>#include<iostream>#include<string>#include<cmath>#include<queue>#include<vector>#include<map>#include<set>using namespace std;const int maxn = 105;int n, f[maxn][maxn], a[maxn][maxn];int main(){while (~scanf("%d", &n)){memset(f, 0, sizeof(f));for (int i = 1; i <= n;i++)for (int j = 1; j <= i; j++) scanf("%d", &a[i][j]);for (int i = n; i; i--)for (int j = 1; j <= i; j++)f[i][j] = a[i][j] + max(f[i + 1][j], f[i + 1][j + 1]);printf("%d\n", f[1][1]);}return 0;}
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
- Cocos2dx如何实现每一帧的触发
- poj 1141 Brackets Sequence
- hdu 5336 XYZ and Drops
- apache2学习笔记
- MongoDB分布式
- POJ 1163The Triangle
- VS2012快捷键
- POJ 1837Balance
- Message Queue under Qt5: zmq + nzmqt + qt
- Fence Repair
- HDU2715 Herd Sums
- veth pair
- [LeetCode] Reverse Nodes in k-Group
- Linux下如何避免僵尸进程的产生