poj1163 简单DP
来源:互联网 发布:在知乎回答问题 编辑:程序博客网 时间:2024/04/27 16:47
思路:
简单DP。
#include <iostream>#include <string>#include <vector>#include <set>#include <map>#include <queue>#include <algorithm>#include <fstream>#include <cmath>#include <cstring>#include <limits.h>#define Long long long#define uint unsigned int#define N#define mod 1000000007#define inf 100000000#define eps 1e-10#define For(i,l,r) for(int i=l;i<=r;i++)#define Dor(i,r,l) for(int i=r;i>=l;i--)using namespace std;ifstream in("/Users/urey/data/input.txt");//_________________________________________________________________________________int n;int data[101][101], record[101][101];int dfs(int layer, int i) { if(layer == n) { return data[layer][i]; } int left = 0, right = 0; if(record[layer][i] == 0) { left = data[layer][i] + dfs(layer + 1, i); right = data[layer][i] + dfs(layer + 1, i + 1); record[layer][i] = max(left, right); } return record[layer][i];}int main(int argc, const char * argv[]) { in>>n; for(int i = 1; i <= n; ++i) { for(int j = 1; j <= i; ++j) { in>>data[i][j]; } } memset(record, 0, sizeof(record)); int sum = dfs(1, 1); cout<<sum<<endl; return 0;}
0 0
- poj1163 简单的dp
- poj1163 简单DP
- POJ1163 The Triangle简单dp
- POJ1163 The Triangle DP简单题
- 最简单的DP问题(POJ1163)
- poj1163 dp
- poj1163——The Triangle(简单dp)
- poj1163 dp水题
- poj1163 递归或dp
- POJ1163 The Triangle 【DP】
- poj1163 dp the triangle
- DP 数字三角形(POJ1163)
- POJ1163 DP水题
- 线性dp A(poj1163)
- POJ1163
- poj1163
- POJ1163
- POJ1163
- poj2886 Who Gets the Most Candies? 线段树加反素数
- 记我的前端起始之路
- Turing equation
- C. Watto and Mechanism
- Android程序与JavaScript之间的简单调用
- poj1163 简单DP
- 黑马程序员----- c语言结构体
- ssh命令通过制定端口连接远程服务器
- 二叉树的基本运算
- 世界上最可怕的搜索引擎--Shodan
- 设计模式之装饰模式
- leetcode | Minimum Path Sum
- strtok函数的用法
- 大数据时代