hdu 1078 FatMouse and Cheese_记忆搜索】的更多相关文章

做这类型的搜索比较少,看懂题意花了半天 题意:给你个n*n的图,老鼠一次最远走k步,老鼠起初在(0,0),每次偷吃的东西必须比之前偷吃的要大. #include<iostream> #include<cstdio> using namespace std; #define N 110 int map[N][N],dp[N][N]; int n,k; int dir[][2]={{1,0},{0,1},{-1,0},{0,-1}}; int solve(int x,int y) {…
HDU 1078 FatMouse and Cheese ( DP, DFS) 题目大意 给定一个 n * n 的矩阵, 矩阵的每个格子里都有一个值. 每次水平或垂直可以走 [1, k] 步, 从 (0, 0) 点开始, 下一步的值必须比现在的值大. 问所能得到的最大值. 解题思路 一般的题目只允许 向下 或者 向右 走, 而这个题允许走四个方向, 所以状态转移方程为 dp(x, y) = dp(nextX, nextY) + arr(x, y); dp 代表在 x, y 的最大值. 由于 下一…
FatMouse and Cheese Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 8610    Accepted Submission(s): 3611 Problem Description FatMouse has stored some cheese in a city. The city can be considere…
pid=1078">FatMouse and Cheese Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 4811    Accepted Submission(s): 1945 Problem Description FatMouse has stored some cheese in a city. The city can…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1078 老鼠初始时在n*n的矩阵的(0 , 0)位置,每次可以向垂直或水平的一个方向移动1到k格,每次移动过去的那个格子里面的数值必须比当前所在格子里面的大,求出路径上所有数值总和最大值. 直接上代码: #include <iostream> #include <cstring> #include <cstdio> using namespace std; ][] , dp[…
http://acm.hdu.edu.cn/showproblem.php?pid=1078 题意: 一张n*n的格子表格,每个格子里有个数,每次能够水平或竖直走k个格子,允许上下左右走,每次走的格子上的数必须比上一个走的格子的数大,问最大的路径和. 记忆化搜索 #include <iostream> #include <string.h> #include <stdio.h> using namespace std; ][] = { {, },{ -, }, {, }…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1078 题意:每次仅仅能走 横着或竖着的 1~k 个格子.求最多能吃到的奶酪. 代码: #include <stdio.h> #include <ctime> #include <math.h> #include <limits.h> #include <complex> #include <string> #include <fun…
题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=1078 题意:给出n*n的格子,每个各自里面有些食物,问一只老鼠每次走最多k步所能吃到的最多的食物 一道简单的记忆化搜索题,从起点开始搜索即可没什么问题,可以拿来练练手. #include <iostream> #include <cstring> #include <algorithm> #include <cstdio> using namespace std…
Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 5701    Accepted Submission(s): 2320 Problem Description FatMouse has stored some cheese in a city. The city can be considered as a square grid of…
FatMouse has stored some cheese in a city. The city can be considered as a square grid of dimension n: each grid location is labelled (p,q) where 0 <= p < n and 0 <= q < n. At each grid location Fatmouse has hid between 0 and 100 blocks of che…