【poj 3176】 Cow Bowling 递推dp

北大POJ3176-Cow Bowling 立即下载

Cow Bowling
Time Limit: 1000MS Memory Limit: 65536K
Total Submissions: 16562 Accepted: 11036

Description
The cows don’t use actual bowling balls when they go bowling. They each take a number (in the range 0..99), though, and line up in a standard bowling-pin-like triangle like this:

      7



    3   8



  8   1   0



2   7   4   4

4 5 2 6 5

Then the other cows traverse the triangle starting from its tip and moving “down” to one of the two diagonally adjacent cows until the “bottom” row is reached. The cow’s score is the sum of the numbers of the cows visited along the way. The cow with the highest score wins that frame.

Given a triangle with N (1 <= N <= 350) rows, determine the highest possible sum achievable.

Input
Line 1: A single integer, N

Lines 2..N+1: Line i+1 contains i space-separated integers that represent row i of the triangle.

Output
Line 1: The largest sum achievable using the traversal rules

Sample Input

5
7
3 8
8 1 0
2 7 4 4
4 5 2 6 5

Sample Output

30

Hint
Explanation of the sample:

      7

     *

    3   8

   *

  8   1   0

   *

2   7   4   4

   *

4 5 2 6 5

The highest score is achievable by traversing the cows as shown above.

Source
USACO 2005 December Bronze

题目链接:http://poj.org/problem?id=3176
题目大意:数字三角形;
思路:递推
代码:

    #include<iostream>
    #include<stdio.h>
    #include<string.h>
    #include<algorithm>
    using namespace std;
    int a[351][351];
    int n;
    int dp[351][351];
    int main()
    {
        scanf("%d",&n);
        for(int i=1;i<=n;i++)
        for(int j=1;j<=i;j++)
        scanf("%d",&a[i][j]);

        dp[1][1]=a[1][1];
        for(int i=2;i<=n;i++)
        for(int j=1;j<=i;j++)
        {
            if(j!=i)
            dp[i][j]=max(dp[i-1][j],dp[i-1][j-1]);
            else dp[i][j]=dp[i-1][j-1];
            dp[i][j]+=a[i][j];
        }
        int ans=0;
        for(int i=1;i<=n;i++)
        ans=max(ans,dp[n][i]);
        printf("%d\n",ans);

    }
RseQC实战指南:从安装到RNA-Seq数据质控全流程解析 本文提供了一份详尽的RseQC实战指南,涵盖从安装配置到RNA-Seq数据质控的全流程。文章重点解析了RseQC作为专业质控工具的核心价值,手把手指导如何通过Conda或pip完成安装,并深入讲解了bam_stat.py、geneBody_coverage.py等关键模块的使用方法与结果解读技巧,帮助用户有效评估RNA完整性、文库构建质量及链特异性,确保下游分析的可靠性。 阅读详情

相关推荐

【实战指南】OpenClaw 使用 Bird Skill 接入 X(Twitter)的终极省心方案:告别每次都要手动喂 Cookie 的痛苦

OpenClaw 使用 Bird Skill 接入 X(Twitter)的终极省心方案:告别每次都要手动喂 Cookie 的痛苦

hampeter的博客 1819

Cow Bowling

The cows don't use actual bowling balls when they go bowling. They each take a number (in the range 0..99), though, and line up in a standard bowling-pin-like triangle like this: 7 ...

songziyuan_的博客 358

FPGA+滨淞CCD实战:手把手教你搭建S7031/S10142成像电路(附避坑指南)

本文详细介绍了使用FPGA驱动滨淞CCD传感器(S7031/S10142)构建高精度成像系统的完整实战流程。内容涵盖核心器件选型、系统架构规划、电路板(焦面板与接口板)设计要点、FPGA Verilog逻辑实现,并提供了从电源管理、信号调理到数据采集的详细避坑指南,帮助读者从零搭建稳定可靠的成像电路。

weixin_29271263的博客 238

Cow Bowling (动态规划)

The cows don't use actual bowling balls when they go bowling. They each take a number (in the range 0..99), though, and line up in a standard bowling-pin-like triangle like this: 7 ...

Lbo_tao的博客 298

【VAE学习笔记】全面通透地理解VAE(Variational Auto Encoder)

完整笔记:http://www.gwylab.com/note-vae.html 李宏毅老师的教程视频:https://www.bilibili.com/video/av15889450/?p=33 —————————————————————————————————   依据李宏毅老师的讲解,我整理了一番VAE的笔记。先简单介绍一下VAE,VAE作为一个生成模型,其基本思路是很容易理解的:把一堆真...

a312863063的博客 14万+

什么是 SAP ABAP Secure Storage

此过程将单独的密钥存储在密钥路径中的密钥文件中,并自动使用新加密密钥加密安全存储中的所有数据记录。需要注意的是,不要在没有命令行工具的情况下操作密钥文件,例如,不要用不同的版本替换密钥文件,否则,安全存储中的数据记录可能变得不可读。当需要访问这些数据时,系统会对其进行解密。文件系统中的安全存储(Secure Storage in the File System)也是 SAP NetWeaver Application Server for ABAP 的一部分,主要用于安全存储连接相关的数据,如密码等。

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 449

Cow Bowling(dp)

The cows don’t use actual bowling balls when they go bowling. They each take a number (in the range 0…99), though, and line up in a standard bowling-pin-like triangle like this: 7 3 8 8 1 0 2 7 4 4 4 5 2 6 5 Then the other cows traverse

weixin_53323126的博客 179

“/usr/lib/wsl/wsl-setup“ failed, exiting

WSL2安装Ubuntu时出现"wsl-setup failed"错误的解决方法 摘要:当Windows用户名包含中文字符时,安装WSL2+Ubuntu会出现"wsl-setup failed"错误。本文提供两种解决方案:1)修改中文用户名(风险较大);2)通过命令手动配置。推荐第二种方法:先使用"wsl -l -v"查看Ubuntu名称,再通过"wsl -d Ubuntu20.04 -e /bin/bash"命令启动WSL2系

猿小白的博客 1006

poj3176

Cow Bowling Time Limit:1000MS Memory Limit:65536K Total Submissions:8553 Accepted:5607 Description The cows don't use actual bowling balls when they go bowl...

weixin_33714884的博客 259

如何卸载Gazebo与重装

gazebo是一款关于车辆和无人机的仿真软件,本文大致介绍它是何物,以及他的安装和卸载方法,对于ROS开发者,本文有一定参考意义。

gongdiwudu的专栏 1万+

基于深度学习的茶叶等级检测识别系统:YOLOv10 + UI界面 + 数据集

YOLOv10是YOLO系列的最新版本,继承了YOLO模型的优点,并对速度和精度进行了优化。YOLOv10在目标检测中使用卷积神经网络(CNN)作为基础,通过改进网络结构和优化训练策略,实现了在更低的延迟下进行高精度的目标检测。本文详细介绍了基于YOLOv10的茶叶等级检测与识别系统的设计与实现过程。我们从数据集准备、模型训练与推理、UI界面设计等多个方面进行了详细讲解,并给出了相应的代码实现。通过本系统,我们可以高效地自动检测茶叶的等级,并通过UI界面直观地展示结果。

YOLO 770

Cow Bowling(POJ--3176

Description The cows don't use actual bowling balls when they go bowling. They each take a number (in the range 0..99), though, and line up in a standard bowling-pin-like triangle like this: 

zhang_di233的专栏 543

C++ PCL点云处理实战专栏

工业级点云处理技术学习资源,涵盖电力、建筑、隧道等领域的实战案例。内容分为三阶段:代码原理(算法认知)、动态库(项目验证)和完整代码(定制开发)。

weixin_45196569的博客 1134

POJ - 3176 Cow Bowling (Dp初步,记忆化搜索递推)

The cows don't use actual bowling balls when they go bowling. They each take a number (in the range 0..99), though, and line up in a standard bowling-pin-like triangle like this:    7 ...

许久的学习小窝 259

OV9734 DATASHEET,完整规格书

OV9734完整规格书,包括电气参数,尺寸规格,寄存器配置表等

VB摄像头监控

该VB模块可对摄像头捕获的画面进行录像等,可在创建的窗口进行控制

【原】 POJ 3176 Cow Bowling 动态规划 解题报告

http://poj.org/problem?id=3176 方法: DP:将大问题转化为小问题解决。由递归写循环。 c[i][j]表示从a[1][1]开始到a[i][j]的最大和。而最终的结果为c[n][1...n]中的最大值 递归式为: c[1][1] = a[1][1] c[i][j] = max{ c[i-1][j-1], c[i-1][...

ajiaxi111111的博客 148

Statistics and Machine Learning Toolbox

Statistics and Machine Learning Toolbox(带书签),MATLAB统计学习工具

POJ 3176 Cow Bowling

POJ 3176题目大意如下: 这里做个抽象,问题背景就省了:有一个三角数堆,从顶点开始加和,找出一条从顶点到底边的最大和路径,求出这个和。 十分简单的Dynamic Programming,可以抽象成: dp[i][j] = value[i][j] + max(dp[i + 1][j] + dp[i + 1][j + 1]); 从上面式子可以看出,其实对于dp数组而言,第一维是没有必要的

kornberg_fresnel的博客 331

Data-Structures-and-Algorithm-Analysis-in-Java.pdf

作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...

poj3176-Cow Bowling【dp】

The cows don't use actual bowling balls when they go bowling. They each take a number (in the range 0..99), though, and line up in a standard bowling-pin-like triangle like this:    7 ...

独钓门前月 520

[dp]poj3176 Cow Bowling

Cow Bowling Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 15103   Accepted: 10047 Description The cows don't use actual bowling balls when they go bowl

童凌的技术博客 500

Cow Bowling POJ 3176(基础dp)

原题 题目链接 题目分析 非常基础的dp题,先把原图存下来,然后在造一个与原图相匹配的dp,dp更新方案如下,如果j==1 则dp[i][j]只能从上一层的dp[i-1][j]更新过来,因此有dp[i][j]=dp[i-1][j],如果j==i,则dp[i][j]只能从上一层的dp[i-1][j-1]更新过来,因此有dp[i][j]=dp[i-1][j-1],否则dp[i][j]可...

dashengchong6303的博客 133

POJ3176-Cow Bowling

这么多天对DP还是研究的不够透彻,DP入门第一题。 初始条件为dp[0][0]=tip的值,其余dp[i][j]取决于dp[i-1][j]和dp[i-1][j-1]和本身dp[i][j]的值。 #include #include #include using namespace std; const int MAXN = 350; int bowl[MAXN+5][MAXN+5];

Collider 339

POJ 3176-Cow Bowling(dp_数字三角形)

Cow Bowling Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Submit Status Description The cows don't use actual bowling balls when they go bowling. They ea

Rocky0429 1738

POJ 3176 Cow Bowling (简单DP)

Cow Bowling http://poj.org/problem?id=3176 Time Limit: 1000MS Memory Limit: 65536K Description The cows don't use actual bowling balls when they go bowling. They each take a num

AC,∑ndless 1454

poj3176cow bowling

天天和这些奶牛打交道我也是蛮拼的=-=。。。。。 介绍一下题意吧就是奶牛在打保龄球,球只能在相邻的数字之间碰撞,求最后总得分 简单的dp,难的也不会做=-= 别的不说先上代码。。#include #include #define M 500 #include #include // 47MS using namespace std; int map[M][M]; int main(

zshdove 446

poj3176 cow bowling

大致题意: 输入一个n层的三角形,第i层有i个数,求从第1层到第n层的所有路线中,权值之和最大的路线。 规定:第i层的某个数只能连线走到第i+1层中与它位置相邻的两个数中的一个。 太简单了,应该是属于那种无脑的dp题目 a[N+1][N+1]存数据(为什么用N+1而不是N呢,因为我们用1-N的下标存,为什么不是0-N-1呢,因为每行的首元素的上一行只有右边,细细

Rainto的专栏 529

poj 3176 Cow Bowling

题目链接:点击打开链接 ps;简单DP, 数字三角形 #include #include using namespace std; int a[400][400]; int main() { int n; cin>>n; for(int i=0;i<n;i++) { for(int j=0;j<=i;j++) {

Vision 314

【poj 3176】Cow Bowling 题意&题解&代码(C++)

poj dp

曾经追梦的happy时光 548
上一篇: 【Poj 2533】 Longest Ordered Subsequence 最长上升子序列
下一篇: 【poj 1080】Human Gene Functions DP(类最长公共子序列*)
ALPS233
博客等级 码龄11年 25粉丝 191原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值