hdu_2391 Filthy Rich DP
Filthy Rich
Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 4393 Accepted Submission(s): 1898
Given a rectangular map and amounts of gold on every field, determine the maximum amount of gold you can collect when starting in the upper left corner of the map and moving to the adjacent field in the east, south, or south-east in each step, until you end up in the lower right corner.
Each test case starts with a line, containing the two integers r and c, separated by a space (1 <= r, c <= 1000). This line is followed by r rows, each containing c many integers, separated by a space. These integers tell you how much gold is on each field. The amount of gold never negative.
The maximum amount of gold will always fit in an int.
一道dp题, 从左上角走到右下角,只能往右、下或右下走,求捡到的金子最多为多少。
#include <iostream>
#include <stdio.h>
#include <string.h> using namespace std; int dp[][]; int Max(int a, int b)
{
return a>b? a:b;
} int main()
{
int t, r, c;
scanf("%d", &t);
for(int i=; i<; i++)
{
dp[i][]=;
dp[][i]=;
}
for(int k=; k<t; k++)
{
scanf("%d%d", &r, &c); for(int i=; i<=r; i++)
for(int j=; j<=c; j++)
{
scanf("%d", &dp[i][j]);
dp[i][j] += Max(dp[i-][j], dp[i][j-]);
}
printf("Scenario #%d:\n", k+);
printf("%d\n\n", dp[r][c]);
} return ;
}
hdu_2391 Filthy Rich DP的更多相关文章
- HDU 2391 Filthy Rich (dp)
题目连接 Problem Description They say that in Phrygia, the streets are paved with gold. You're currently ...
- hdu 2391 Filthy Rich
单纯dp 水一 处理时间点,第一行和第一列特殊处理: 其余的w[i][j]=show(w[i-1][j-1],w[i-1][j],w[i][j-1]); <span style="fo ...
- (转) [it-ebooks]电子书列表
[it-ebooks]电子书列表 [2014]: Learning Objective-C by Developing iPhone Games || Leverage Xcode and Obj ...
- JAVA 画图机制
java学习脚印:深入java绘图机制 写在前面 封装性越好的类在使用时,只要清楚接口即可,而不应该让程序员了解其内部结构; 对于平常的绘图来讲,java绘图机制无需了解太多,但是朦胧容易产生错误,绘 ...
- ACM: 强化训练-Beautiful People-最长递增子序列变形-DP
199. Beautiful People time limit per test: 0.25 sec. memory limit per test: 65536 KB input: standard ...
- hdu--(1025)Constructing Roads In JGShining's Kingdom(dp/LIS+二分)
Constructing Roads In JGShining's Kingdom Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65 ...
- 你有PSD的学位吗? - dp的日志 - 网易博客
你有PSD的学位吗? - dp的日志 - 网易博客 你有PSD的学位吗? 2011-08-01 12:58:40| 分类: 感悟 | 标签:自我提升 |字号 大中小 订阅 去年, ...
- (中等) POJ 2948 Martian Mining,DP。
Description The NASA Space Center, Houston, is less than 200 miles from San Antonio, Texas (the site ...
- Humble Numbers HDU - 1058 2分dp
JGShining's kingdom consists of 2n(n is no more than 500,000) small cities which are located in two ...
随机推荐
- docker下简单搭建redis
前提是我们已经安装了docker 一.拉取官方镜像,标签为3.2 # docker pull redis:3.2 等待下载完成后我,我们可以在本地镜像列表中查到repository 为redis,标签 ...
- resetFields() 有时无效问题
elementui在重置表单时,无法使用this.$refs['formRefVal'].resetFields()清空表单数据; elementui 设置rules后没有效果 解决方法: prop属 ...
- spring-cloud feign的多参数传递方案
查看原文 一.GET请求多参数URL 1.方法一(推荐) @FeignClient(“microservice-provider-user”) public interface UserFeignCl ...
- HAproxy shell脚本安装
#!/bin/bash #需要lua-..tar.gz在家目录下 # 编译安装lua #安装编译环境需要的包 yum -y install gcc openssl-devel pcre-devel s ...
- 二、Python2.7的安装并与Python3.8共存
一:Python解释器为什么要2个版本? 众所周知,Python2.7是一个过渡版本. 很多公司写的项目并不是基于最新的Python3写的,在之后进行一些项目更改的时候,Python3的语法有一些并不 ...
- 对象中属性 加锁 用:volatile 关键词修饰 而 不用 synchronized 加锁
一个对象中有一个状态 属性,现在业务需求 存在多线程来修改 和 拿去 这个状态 的值,这种情况如果加锁怎么加? 一种是 在 set 和get 这个状态的 方法那加 synchronized . 还有一 ...
- syncronized如何上锁
上锁,根据操作系统所说的原则,对共享变量上锁,对临界区上锁.谁访问临界资源?就给谁上锁 同步监视器,它上锁的对象. 1.用关键字给方法上锁 2.用synchronized代码块上锁 默认上锁对象:th ...
- AJ学IOS(41)UI之核心动画 两行代码搞定3D转场
AJ分享,必须精品 效果: 代码: 其实代码很少,苹果都给封装好了 // 1.创建核心动画 CATransition *ca = [CATransition animation]; // 1.1动画过 ...
- 03-css3中的3D转换
一.CSS3-3D转换 1.3D 特点:近大远小,物体和面遮挡不可见 1.1三维坐标系 x 轴:水平向右 -- x 轴右边是正值,左边是负值 y 轴:垂直向下 -- y 轴下面是正值,上面是负值 z ...
- 深入理解JS原型与原型链
函数的prototype 1.函数的prototype属性 *每个函数都有一个prototype属性,它默认指向一个Object空对象(即称为原型对 象) * 原型对象中都有一个属性construct ...