
ACM-递归&分治
3stone_
别想了,动手吧
展开
-
递归--九度1458.汉诺塔3
题意: 改变游戏的玩法,不允许直接从最左(右)边移到最右(左)边(每次移动一定是移到中间杆或从中间移出),也不允许大盘放到下盘的上面。现在有N个圆盘,她至少多少次移动才能把这些圆盘从最左边移到最右边?递归式:F(n) = 3F(n-1)+2 递归基:F(1) = 2#include<cstdio>using namespace std;long long F(int n) {//递归返回值较大原创 2017-02-19 09:08:57 · 544 阅读 · 0 评论 -
递归--【全排列问题】九度1459.Prime ring problem
题目:http://ac.jobdu.com/problem.php?pid=1459#include<cstdio>#include<iostream>#include<cstring>#include<string>#include<cmath>#include<algorithm>#define maxSize 10010using namespace std;/*全排列问原创 2017-02-19 11:27:14 · 387 阅读 · 0 评论 -
递归--九度1120.全排列
#include<cstdio>#include<iostream>#include<string>#include<algorithm>#define maxSize 10using namespace std;/*全排列问题:使用hash数组,下标表示数字,内容为true/false表示是否已探测过递归算法:假设0到(index-1)已经满足,讨论与index位的情况递归基:原创 2017-02-19 23:17:53 · 321 阅读 · 0 评论 -
递归--九度1460.Oil Deposit【待优化】
题目: http://ac.jobdu.com/problem.php?pid=1460 【代码需重写,太糙了】 类似于n皇后问题:使用hash数组,下标表示数字,内容为true/false表示是否已探测过 递归算法:DFS搜索 递归基:遍历一遍即可#include<cstdio>#include<iostream>#include<cstring>#include<string>#原创 2017-02-19 16:32:34 · 283 阅读 · 0 评论