hdu1978(记忆化搜索/DP)
来源:互联网 发布:剑3唐门成男捏脸数据 编辑:程序博客网 时间:2024/04/28 12:19
题目链接:hdu1978
/*记忆化搜索。深搜到终点,回溯时记录到达终点的不同路径数*/#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>#include <cmath>using namespace std;const int inf = 0x3f3f3f3f;const int N = 105;const int mod = 10000;int a[N][N],d[N][N],n,m;int dfs(int x, int y){ if(d[x][y]) return d[x][y]; if(x == n && y == m) return 1;//到达终点 int cnt = a[x][y], sum = 0; for(int i = 0; i <= cnt; i ++) for(int j = 0; j <= cnt; j ++){ if(i+j > 0 && x+i <= n && y+j <= m && i+j <= cnt) sum += dfs(x+i, y+j); sum %= mod; } d[x][y] = sum; return sum;}int main(){ int x,i,j,T; scanf("%d",&T); while(T--) { scanf("%d%d",&n,&m); for(i = 1; i <= n; i ++) for(j = 1; j <= m; j ++) scanf("%d",&a[i][j]); memset(d, 0, sizeof(d)); printf("%d\n", dfs(1,1)); } return 0;}
0 0
- hdu1978(记忆化搜索/DP)
- HDU1978 记忆化搜索
- HDU1978 记忆化搜索
- HDU1978 记忆化搜索
- 记忆化dp hdu1978
- hdu1978 How many ways--DP/记忆化搜索DFS
- hdu1978 简单记忆化搜索
- HDU1978-How many ways(记忆化搜索)
- hdu1978——How many ways(记忆化dp)
- hdu1978--How many ways(记忆化搜索)
- 记忆化搜索(搜索+动态规划)HDU1978 How Many Ways
- 人生中第一个记忆化搜索题 hdu1978
- 动态规划、记忆化搜索:HDU1978-How many ways
- 记忆化搜索(搜索+dp思想)
- dp记忆化搜索
- 记忆化搜索,dp
- 记忆化搜索DP
- poj 1088 (dp记忆化搜索)
- u-boot源码配置原理分析
- 宽屏透明html5产品展示模板
- mouseover事件与mouseenter事件
- 黑马程序员——交通灯管理系统学习总结
- 本文介绍在Wireshark网络协议分析仪中如果解密SSL和TLS流量
- hdu1978(记忆化搜索/DP)
- C语言基础——new/delete与malloc/free比较
- linux下查看系统资源和负载,以及性能监控
- git 使用
- Linux查看版本当前操作系统信息
- Linux 常用快捷键
- 八数码问题
- SEO教你软文怎样写才能招引用户与搜索引擎
- ZOJ 3781 Paint the Grid Reloaded