poj 3176 Cow Bowling(最简单DP题)
来源:互联网 发布:网络监控工程公司 编辑:程序博客网 时间:2024/05/22 19:27
数字三角形,从头开始走,往下走,每次只能选择左或右,问走到最底最大的数是多少。
学长说这是最简单的DP题,可能连DP都算不上。
自己推出了状态转移方程,但是遍历的时候不知道从底开始往上遍历,最后输出dp[0][0]就ok了。
代码:
#include<stdio.h>#include<algorithm>using namespace std;int main(){ #ifdef LOCAL freopen("in.txt","r",stdin); #endif // LOCAL int N; int dp[351][351]; int a[351][351]; while(scanf("%d", &N)!=EOF) { for(int i = 0; i < N; i++) { for(int j = 0; j < N; j++) { scanf("%d", &a[i][j]); dp[i][j] = a[i][j]; if(i == j) break; } } for(int i = N - 1; i >= 0; i--)//debug { for(int j = 0; j < N; j++) { dp[i][j] = a[i][j] + max(dp[i + 1][j], dp[i + 1][j + 1]); if(i == j) break; } } printf("%d\n", dp[0][0]); } return 0;}
0 0
- poj 3176 Cow Bowling(最简单DP题)
- POJ 3176 Cow Bowling (简单DP)
- POJ 3176 Cow Bowling (简单DP)
- POJ 3176-Cow Bowling (简单DP)
- POJ 3176 Cow Bowling (简单DP)
- POJ 3176 Cow Bowling(简单DP)
- POJ-3176-Cow Bowling-(简单dp)
- POJ 3176 Cow Bowling DP
- poj-3176-Cow Bowling-dp
- poj 3176 Cow Bowling (DP)
- poj 3176 Cow Bowling dp
- POJ 3176 Cow Bowling DP
- poj 3176Cow Bowling DP
- Poj 3176 Cow Bowling【dp】
- POJ 3176 Cow Bowling (dp)
- POJ-3176 Cow Bowling 数塔,简单DP
- poj 3176 -- Cow Bowling (dp)
- poj 3176 Cow Bowling 数塔dp
- iOS - 正则表达式判断邮箱、身份证...
- 我写过的歌词正是我所想说的话
- 如何在Visual Studio 10.0中设置Halcon机器视觉
- Codeforces Round #243 (Div. 2) C. Sereja and Swaps 解题报告
- hibernate一对多异常 ERROR: ORA-00904: "CITY0_"."AID": 标识符无效
- poj 3176 Cow Bowling(最简单DP题)
- tomcat 配置虚拟目录
- Java中常用的加密方法(JDK)
- Making a Plugin System
- 编程为什么困难
- 关于修真、法力、法术、武功等的介绍
- 循环buffer
- Android UI–Style 和 Theme
- 边缘方向直方图