DFS
芋智波佐助
菜鸟一只
展开
-
UVa 208 Firetruck / dfs + floyd
给你一个无向图 和一个点 n 按字典序打印所有的从1到n路径 直接深搜 回溯 会TLE 剪个枝 先做一次floyd 如果途经 i点 判断从i 到 n是否可达 不可达就不用搜下去了#include #include #include #include using namespace std;int a[100][100];int b[100][100];int map[100];原创 2013-12-06 22:48:05 · 925 阅读 · 0 评论 -
Light OJ 1341 Aladdin and the Flying Carpet Pollard_rho整数分解+DFS
输入a b 求有多少对p, q 使得p*q == a && p = b直接大整数分解 然后dfs搜出所有可能的解#include #include #include #include #include using namespace std;typedef long long LL;const int Times = 25;LL factor[100], f[100];i原创 2014-10-09 15:00:04 · 1111 阅读 · 0 评论 -
TOJ 3504 Repeatless Numbers / 深搜
Repeatless Numbe时间限制(普通/Java):1000MS/3000MS 运行内存限制:65536KByte 描述Arepeatless number is a positive integer containing no repeated digits. For instance, the first 25 repeatless numbers原创 2013-11-07 22:57:22 · 1581 阅读 · 0 评论 -
TOJ 4267 An Easy Puz / 深搜
An Easy Puz时间限制(普通/Java):1000MS/3000MS 运行内存限制:65536KByte描述Wddpdh find an interesting mini-game in the BBS of WHU, called “An easy PUZ”. It’s a 6 * 6 chess board and each cell has a原创 2013-11-05 17:01:05 · 1108 阅读 · 0 评论 -
UVa 11464 Even Parity / 深搜
算是一类的题目 zoj也看到过 今天终于写了给你一个0 1 的矩阵 可以把0变成1 1 不能变成0 然后最小的变换次数是每一个位置的上下左右加起来的和是偶数枚举第一行 根据第一行下面的都已经确定了 O(2^n*N*N)#include #include const int MAX = 20;int n;int min;int a[MAX][MAX];int b[MAX][M原创 2013-11-05 13:48:26 · 1102 阅读 · 0 评论 -
TOJ 2921 古韵之鹊桥相会 / 深搜
古韵之鹊桥相会时间限制(普通/Java):1000MS/3000MS 运行内存限制:65536KByte描述迢迢牵牛星,皎皎河汉女。纤纤擢素手,札札弄机杼;终日不成章,泣涕零如雨。河汉清且浅,相去复几许?盈盈一水间,脉脉不得语。——《古诗十九首》传说,上古时期的某个七月七日,王母娘娘为了阻止牛郎织女的爱情,划一道玉钗拆散鸳鸯,使两人“原创 2013-11-01 15:00:33 · 1566 阅读 · 0 评论 -
TOJ 4367 ZOJ 3631 Watashi's BG / 背包 深搜
Watashi's BG时间限制(普通/Java):1000MS/3000MS 运行内存限制:65536KByte描述Watashi is the couch of ZJU-ICPC Team and he is very kind hearted. In ZJU-ICPC summer training camp, students are divided原创 2013-10-19 10:04:42 · 1178 阅读 · 0 评论 -
TOJ 1183 HDU 1515 ZOJ 1004 Anagrams by Stack /深搜+栈
Anagrams by Stack 时间限制(普通/Java):1000MS/10000MS 运行内存限制:65536KByte描述How can anagrams result from sequences of stack operations? There are two sequences of stack operators which can c原创 2013-08-22 23:31:19 · 1441 阅读 · 0 评论 -
POJ 1011 Sticks DFS+剪枝
#include #include #include using namespace std;bool cmp(int a,int b){ return a > b;}int map[70];int a[70];int n,sum,m,flag;bool dfs(int s, int len, int x, int sum, int num){原创 2016-07-18 09:03:54 · 218 阅读 · 0 评论