地址:http://poj.org/problem?id=3176

题目解析:没什么好说的,之前上课时老师讲过。从下往上找,每一个三角形的顶点可由两个角加上顶点的值 两种方式得到 ,用dp数组保存下最大值即可。

#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <queue>
#include <math.h>
#define N 400
#define inf 0x3f3f3f3f
typedef int ll;
using namespace std;
int a[N][N],dp[N][N];
int main()
{
int n;
while(scanf("%d",&n)!=EOF)
{
for(int i=; i<=n; i++)
{
for(int j=; j<=i; j++)
scanf("%d",&a[i][j]);
}
for(int i=; i<=n; i++)
{
dp[n][i]=a[n][i];
}
for(int i=n-; i>=; i--)
{
for(int j=; j<=i; j++)
{
dp[i][j]=max(a[i][j]+dp[i+][j],a[i][j]+dp[i+][j+]);
}
}
printf("%d\n",dp[][]);
}
return ;
}

POJ3176:Cow Bowling(数字三角形问题)的更多相关文章

  1. POJ3176——Cow Bowling(动态规划)

    Cow Bowling DescriptionThe cows don't use actual bowling balls when they go bowling. They each take ...

  2. POJ3176 Cow Bowling 2017-06-29 14:33 23人阅读 评论(0) 收藏

    Cow Bowling Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 19173   Accepted: 12734 Des ...

  3. Poj3176 Cow Bowling (动态规划 数字三角形)

    Description The cows don't use actual bowling balls when they go bowling. They each take a number (i ...

  4. poj-3176 Cow Bowling &&poj-1163 The Triangle && hihocoder #1037 : 数字三角形 (基础dp)

    经典的数塔模型. 动态转移方程:  dp[i][j]=max(dp[i+1][j],dp[i+1][j+1])+p[i][j]; #include <iostream> #include ...

  5. POJ_3176_Cow_Bowling_(数字三角形)_(动态规划)

    描述 http://poj.org/problem?id=3176 给出一个三角形,每个点可以走到它下面两个点,将所有经过的点的值加起来,问最大的和是多少. Cow Bowling Time Limi ...

  6. POJ 3176 Cow Bowling(dp)

    POJ 3176 Cow Bowling 题目简化即为从一个三角形数列的顶端沿对角线走到底端,所取得的和最大值 7 * 3 8 * 8 1 0 * 2 7 4 4 * 4 5 2 6 5 该走法即为最 ...

  7. G:数字三角形

    总时间限制: 1000ms 内存限制: 65536kB描述73   88   1   02   7   4   44   5   2   6   5 (图1) 图1给出了一个数字三角形.从三角形的顶部 ...

  8. POJ 3176 Cow Bowling

    Cow Bowling Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 13016   Accepted: 8598 Desc ...

  9. 4829 [DP]数字三角形升级版

    4829 [DP]数字三角形升级版  时间限制: 1 s  空间限制: 16000 KB  题目等级 : 黄金 Gold 题解       题目描述 Description 从数字三角形的顶部(如图, ...

随机推荐

  1. shell向python传参数

    想要在shell中调用python脚本时实现: python pyServer.py argu1 argu2 argu3 利用 sys.argv 即可读取到 相应参数: # coding=utf-8 ...

  2. Desugar Scala(16) -- Lower Bound

    欢迎关注我的新博客地址:http://cuipengfei.me/ Lower bound,不知道这个词的确切中文翻译是怎样的.我们直接看例子吧. 1 2 3 class Pair[T](val fi ...

  3. 视图矩阵的推导-opengl应用

    把物体从世界坐标系转化到视点坐标系的矩阵称为视图矩阵. 下面我们先看下opengl视图矩阵的推导过程: 假设视点或camera的局部坐标系为UVN,UVN分别指向右方.上方和后方从而构成右手坐标系,视 ...

  4. css字体属性相关。

    出处:CSS 参考手册    http://www.w3school.com.cn/cssref/index.asp text-decoration 属性 说明:这个属性允许对文本设置某种效果,如加下 ...

  5. virtualbox pxe启动

    在设置——系统中更改启动顺序,优先使用网路启动,如果你的网络环境支持PXE启动,就可以使用网络安装了. 转自: http://blog.csdn.net/huanghuibai/article/det ...

  6. [WPF]实现密码框的密码绑定

    正如绑定TextBox控件的Text属性一样, 我们希望能够将PasswordBox空间的Password属性进行绑定, 比如在MVVM模式中,这似乎是必须的, 但可惜的是, Password属性是不 ...

  7. Object和Function谁先被创建

    http://bbs.csdn.net/topics/390772104#post-397284029

  8. JBPM4 经常使用表结构及其说明

    首先我想说.这不一篇原创博文. 这里设置成原创.主要是为了分享,由于它对于jbpm的刚開始学习的人,真的值得一看.原作者的博文地址并没有查到,我是在还有一位转载此文的博主那儿获得的.地址在这儿. 本文 ...

  9. GIS Cesium地图数据配置

    1.打开IIS,点击站点 2.跨域配置 配置方式: 在地图数据目录之中放置web.config文件,里面存放 <?xml version="1.0" encoding=&qu ...

  10. 【BZOJ2982】combination Lucas定理

    [BZOJ2982]combination Description LMZ有n个不同的基友,他每天晚上要选m个进行[河蟹],而且要求每天晚上的选择都不一样.那么LMZ能够持续多少个这样的夜晚呢?当然, ...