随笔分类 -  算法_搜索

123123
摘要:#includeint map[11][11];int hang_hash[11][11];int lie_hash[11][11];int box[11][11];int shudu[11][11] = {{0}, {0,1,1,1,2,2,2,3,3,3}, {0,1,1,1,2,2,2,3,3,3}, {0,1,1,1,2,2,2,3,3,3}, {0,4,4,4,5,5,5,6,6,6}, {0,4,4,4,5,5,5,6,6,6}, {0,4,4,4,5,5,5,6,6,6}, {0,7,7,7,8,8,8,9,9,9}, ... 阅读全文
posted @ 2013-07-08 21:42 wwjyt 阅读(276) 评论(0) 推荐(0)
搜索____深搜 学易错点
摘要:可直接看出:4行 5列 起点到终点步数为7(从0开始)转化:转为只能往 → 与 ↓ 走的DFS易错:dfs到下一个点,注意是判断 r+1 #define ROW 5#define COL 4int count = 0;void dfs(int r, int c, int n){ if(n == 7) { count++; return; } if(r+1 < ROW) dfs(r+1, c, n+1); if(c+1 < COL) dfs(r, c+1, n+1); }int main(... 阅读全文
posted @ 2013-07-04 12:19 wwjyt 阅读(182) 评论(0) 推荐(0)
pair queue____多源图广搜
摘要:1、简介 class pair ,中文译为对组,可以将两个值视为一个单元。对于map和multimap,就是用pairs来管理value/key的成对元素。任何函数需要回传两个值,也需要pair。 该函数的相关内容如下所示: |->Type----->struct |->Include---> |->Define----> pair(first,second) | |->member | |------>first | |------>second... 阅读全文
posted @ 2013-06-24 15:27 wwjyt 阅读(387) 评论(0) 推荐(0)
深度优先____39级台阶
摘要:#include int count = 0;void dfs(int all,int step){ if(all>39) return; if(all==39 && step%2==0) { count++; return; } if(all<=37)dfs(all+2,step+1); if(all<=38)dfs(all+1,step+1);}int main(){ dfs(0,0); printf("%d\n",count);}//结果:51167078 阅读全文
posted @ 2013-05-07 20:33 wwjyt 阅读(129) 评论(0) 推荐(0)