poj 1163 The Triangle
来源:互联网 发布:诸宸的悲剧 知乎 编辑:程序博客网 时间:2024/06/07 23:56
自下之上求出每一个元素对应的最大值
dp[i][j] = max (dp[i][j]+dp[i-1][j],dp[i][j]+dp[i-1][j+1]);
#include<iostream>#include<string.h>#include<math.h>#include<fstream>#include<algorithm>#include<stdio.h>#include<queue>#include<vector> #define MAXSIZE 100using namespace std;int n = 0;int dp[101][101]; int main(){ //freopen("data_1163.txt","r",stdin); while(scanf("%d", &n) != EOF) { memset(dp, 0, sizeof(dp)); for (int i = 1; i <=n; i++) { for (int j = 1; j <= i; j++) { scanf("%d", &dp[i][j]); } } for (int i = n; i >= 2; i--) { for (int j = i - 1; j >= 1; j--) { dp[i - 1][j] = max (dp[i-1][j]+dp[i][j], dp[i-1][j]+dp[i][j+1]); } } printf("%d\n", dp[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
- 设计模式之策略模式——极客学院学习笔记
- WebBrowser与IE的关系,如何设置WebBrowser工作在IE9模式下?
- gdb和gcc升级:解决编译和调试时出现gdb no symbol in current context
- PHP自动登录的实现和Cookie的安全性(UCHome的实现方法)
- 设计模式之十八:桥接模式(Bridge)
- poj 1163 The Triangle
- 实验一 离散时间序列卷积和MATLAB实现
- Labview与其他应用程序的接口设计
- OJ-多态性
- 深度学习及课题研究杂谈(一)
- Python偏函数
- Notification与Delegate实现通讯沙拉实例
- 算法——排序算法个人总结
- Android <include />用法