DFS
介绍经典的dfs的题目
随意凯
这个作者很懒,什么都没留下…
展开
-
POJ 3134
DescriptionStarting with x and repeatedly multiplying by x, we can compute x31 with thirty multiplications:x2 = x × x, x3 = x2 × x, x4 = x3 × x, …, x31 = x30 × x.The operation of squaring can be appreciably shorten the sequence of multiplications. The f原创 2020-08-28 20:30:05 · 206 阅读 · 0 评论 -
poj 1011 一起成为剪枝er吧
DescriptionGeorge took sticks of the same length and cut them randomly until all parts became at most 50 units long. Now he wants to return sticks to the original state, but he forgot how many sticks he had originally and how long they were originally. Pl原创 2020-08-28 12:14:41 · 143 阅读 · 0 评论 -
leetcode 87. 扰乱字符串——动态规划或者递归
这道题被列为困难,确实难度大。我起初根本没想到能用动态规划解决,但是递归还是比较好理解的。方法一:递归借的一张图片情况一表示不交换顺序,看s1是否等于t1&&s2是否等于t2情况二表示交换顺序,看之前的s1是否等于s2&&s2是否等于s1(图中没有按照之前的标出,那就靠颜色区分吧)然后不断递归即可注意:如果不剪枝,会超时剪枝:1. 如果字符串为一个字符,直接判断即可2. 可以通过map统计字符个数来判断代码class Solution {publ原创 2020-06-30 10:07:53 · 229 阅读 · 0 评论 -
POJ Smallest Difference的几种解法
介绍几种解法,但只有全排列一个可以AC,dfs可以算出正确答案,但是会超时原创 2020-04-30 11:54:08 · 205 阅读 · 0 评论 -
AOJ 0525 Osenbei——DFS解决穷竭搜索问题
利用DFS和位数组来快速解决这道题原创 2020-04-29 17:35:57 · 131 阅读 · 0 评论