dfs POJ 3717 移动路线
2010-10-10 15:47
218 查看
这题比之前做的搜索题水很多,根本不用标记,因为每次走不同的地方,都不会返回,蚂蚁只能向上或友行
这里转换了一下,题目是从左下角到右上角,我求的是左上角到右下角,结果是一样地~
这里转换了一下,题目是从左下角到右上角,我求的是左上角到右下角,结果是一样地~
#include<iostream> using namespace std; int m, n; int count = 0; void dfs(int , int); int main() { //freopen("C:\\Users\\Haojian\\Desktop\\test.txt", "r", stdin); while (cin >> m >> n) { count = 0; dfs(0,0); cout << count << endl; } return 0; } void dfs (int x, int y) { if (x == m-1 && y == n-1) { count++; return; } else { if (x+1 < m && y < n) dfs(x+1, y); if (x < m && y + 1 < n) dfs(x, y+1); } }
相关文章推荐
- poj 3717: 移动路线
- bzoj 1954 & poj 3764 The xor-longest Path dfs+Trie
- POJ 2676 SuDoKu DFS
- dfs-poj-1321-棋盘问题
- POJ 1321-棋盘问题 简单搜索DFS
- 文章标题 POJ 1426 :Find The Multiple (dfs)
- poj Flip Game(DFS)(枚举)
- poj1562--Oil Deposits(DFS)
- POJ 题目1426 Find The Multiple(DFS)
- POJ_3009_DFS
- POJ 2818 : Making Change - dfs
- poj 1129 四色原理DFS
- PoJ 1041 John's trip 神奇操作DFS
- POJ 3984 迷宫问题 DFS
- POJ 2488 DFS水题
- POJ 1321 棋盘问题(DFS)
- POJ 3134 Power Calculus ID-DFS +剪枝
- poj1321 dfs
- 【POJ】-3620-Avoid The Lakes(DFS)
- POJ 1315 Don't Get Rooked(dfs)