andre_joy

导航

2012年8月19日

hdu 1208

摘要: 地址:http://acm.hdu.edu.cn/showproblem.php?pid=1208题意:走迷宫,每个格子里面数字代表与下一个格子间隔是几,求有多少种走法到n。mark:记忆化搜索。本来觉得直接暴力搜索可过,结果tle了。dp[i][j]存放该格子有多少总走法。代码:#include <stdio.h>#include <string.h>#include <stdlib.h>int n;char a[40][40];int s[40][40];long long dp[40][40];int tab[2][2] = {1, 0, 0, 1}; 阅读全文

posted @ 2012-08-19 20:06 andre_joy 阅读(238) 评论(0) 推荐(0) 编辑

hdu 1078

摘要: 地址:http://acm.hdu.edu.cn/showproblem.php?pid=1078题意:老鼠偷吃,有n*n的方阵,每个格子里面放着一定数目的粮食,老鼠每次只能水平或竖直最多走k步,每次必须走食物比当前多的格子,问最多吃多少食物。mark:记忆化搜索。代码:#include <stdio.h>#include <string.h>#include <stdlib.h>int n,m,max1;int s[110][110],dp[110][110];int tab[4][2] = {1, 0, -1, 0, 0, 1, 0, -1};int m 阅读全文

posted @ 2012-08-19 16:14 andre_joy 阅读(750) 评论(0) 推荐(0) 编辑

hdu 1074

摘要: 地址:http://acm.hdu.edu.cn/showproblem.php?pid=1074题意:有很多作业,没有在规定时间内完成要扣分,一天一分,求最小扣分!mark:wa了两次,傻了。。把题意理解错了。是超过期限一天就扣一分!!! 状态压缩dp。dp[i]代表第i个状态的最小罚时,由于本题要输出顺序,所以给dp加上了一个变量,是该状态是由哪个状态来的。代码:#include <stdio.h>#include <string.h>#include <stdlib.h>const int M = (1 << 15);typedef str 阅读全文

posted @ 2012-08-19 13:24 andre_joy 阅读(156) 评论(0) 推荐(0) 编辑