POJ 3176 Cow Bowling
2016-08-02 20:29
302 查看
/* 输入一个n层的三角形,第i层有i个数, 求从第1层到第n层的所有路线中,权值之和最大的路线。 规定:第i层的某个数只能连线走到第i+1层中与它位置相邻的两个数中的一个。 就是一个数塔 dp[i][j] += max(dp[i+1][j], dp[i+1][j+1]); 7 3 8 8 1 0 2 7 4 4 4 5 2 6 5 */ #include <iostream> #include <algorithm> #include <cstdio> #include <cstring> #include <queue> #include <vector> #include <cmath> #include <stack> #include <map> #include <set> #define pi acos(-1) #define LL long long #define INF 0x3f3f3f3f using namespace std; const int maxn = 500 + 5; int dp[maxn][maxn]; int main(void) { // freopen("C:\\Users\\wave\\Desktop\\NULL.exe\\NULL\\in.txt","r", stdin); int n, i, j, k; cin >> n; for (i = 1; i <= n; i++){ for (j = 1; j <= i; j++){ scanf("%d", &dp[i][j]); } } for (i = n-1; i >= 1; i--){ for (j = 1; j <= i; j++){ dp[i][j] += max(dp[i+1][j], dp[i+1][j+1]); } } cout << dp[1][1] << endl; return 0; }
相关文章推荐
- POJ 3176 Cow Bowling
- poj 3176 Cow Bowling 数塔dp
- Poj 3176 Cow Bowling
- POJ 3176 Cow Bowling
- POJ 3176 Cow Bowling
- poj 3176 Cow Bowling
- poj 3176 Cow Bowling
- POJ 3176:Cow Bowling
- poj 1163 The Triangle &poj 3176 Cow Bowling (dp)
- 【poj 3176】 Cow Bowling 递推dp
- poj 3176 Cow Bowling
- 【POJ】3176 - Cow Bowling(dp)
- poj 3176 Cow Bowling (DP)
- POJ 3176 Cow Bowling
- poj 3176 Cow Bowling
- poj-3176-Cow Bowling
- poj 3176 Cow Bowling 简单DP
- poj-3176-Cow Bowling-dp
- poj 3176 Cow Bowling(最简单DP题)
- Cow Bowling--POJ 3176