题目

简单dp

//简单的dp
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int dp[][];//dp[i][j] di i ceng di j ge zui da he
int a[][]; int main()
{
int t;
scanf("%d",&t);
while(t--)
{
int n;
scanf("%d",&n);
for(int i=;i<=n;i++){
for(int j=;j<=i;j++){
scanf("%d",&a[i][j]);
}
}
memset(dp,,sizeof(dp)); for(int i=;i<=n;i++)
{
for(int j=;j<=i;j++)
{
dp[i][j]=a[i][j]+max(dp[i-][j-],dp[i-][j]);
}
}
int ans=-;
for(int i=;i<=n;i++)ans=max(ans,dp[n][i]);
printf("%d\n",ans);
}
return ;
}

hdu 2084 数塔(简单dp)的更多相关文章

  1. hdu 2084 数塔 (简单dp)

    http://acm.hdu.edu.cn/showproblem.php?pid=2084 数塔 Time Limit: 1000/1000 MS (Java/Others)    Memory L ...

  2. HDU 2084 数塔(简单DP入门)

    数塔 Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submiss ...

  3. HDU 2084 数塔 (dp)

    题目链接 Problem Description 在讲述DP算法的时候,一个经典的例子就是数塔问题,它是这样描述的: 有如下所示的数塔,要求从顶层走到底层,若每一步只能走到相邻的结点,则经过的结点的数 ...

  4. HDU 2084 数塔 (DP)

    数塔 Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status Pr ...

  5. 题解报告:hdu 2084 数塔(递推dp)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2084 Problem Description 在讲述DP算法的时候,一个经典的例子就是数塔问题,它是这 ...

  6. HDU 2084 数塔(动态规划)

    数塔 http://acm.hdu.edu.cn/showproblem.php?pid=2084 Problem Description 在讲述DP算法的时候,一个经典的例子就是数塔问题,它是这样描 ...

  7. HDOJ.2084 数塔(DP)

    数塔 点我挑战题目 题意分析 DP的思想,自上而下计算. [这几天比较忙 有空补上] 代码总览 /* Title:HDOJ.2084 Author:pengwill Date:2017-1-14 */ ...

  8. ACM 杭电HDU 2084 数塔 [解题报告]

    数塔 Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submissi ...

  9. HDU 2084 数塔 (动态规划DP)

    原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=2084 题目分析:此题采用动态规划自底向上计算,如果我们要知道所走之和最大,那么最后一步肯定是走最后一排 ...

随机推荐

  1. 转 java面试题

    ● 简述synchronized?Object:Monitor机制: ● 简述happen-before规则 : ● JUC和Object : Monitor机制区别是什么 : 简述AQS原理 : ● ...

  2. swift 2.0 语法 字典

    //: Playground - noun: a place where people can play import UIKit /*: 字典 * 和OC的区别 * 1. {} 替换为 [] * 2 ...

  3. 【http代理报文】自己开发HTTP代理工具,不限语种。

    我们知道通过修改浏览器设置可以使用代理访问网页,其实这个操作就是修改了每次的HTTP头. 工作中,我们难免需要通过TCP/IP协议发送HTTP报文来直接请求网页内容(比如爬虫工具),有同学问如何通过H ...

  4. Uva 11151 - Longest Palindrome

    A palindrome is a string that reads the same from the left as it does from the right. For example, I ...

  5. MT4调用Windows API进行文件读写操作

    /*导入相关函数*/ #import "kernel32.dll" int CreateDirectoryW(string directoryName,int type); int ...

  6. hdu 6201(最小费用最大流)

    transaction transaction transaction Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 132768/1 ...

  7. bzoj 1022 小约翰的游戏John

    题目大意: n堆石子,两个人轮流取石子,每个人取的时候,可以随意选择一堆石子 在这堆石子中取走任意多的石子,但不能一粒石子也不取,取到最后一粒石子的人算输 思路: 首先当每堆石子数都为1时,偶数为先手 ...

  8. 洛谷 P4178 Tree —— 点分治

    题目:https://www.luogu.org/problemnew/show/P4178 这道题要把 dep( dis? ) 加入一个 tmp 数组里,排序,计算点对,复杂度很美: 没有写 sor ...

  9. linux_bash_shell_cheat_sheet(自译)

    [说明] 发现错误或不足请务必联系我!!! linux_bash_shell_cheat_sheet.pdf (英文原本以及译本下载,链接失效请私信或邮箱联系)

  10. 仪表盘(Speedometer) icon 设计