
枚举
努力的气球
这个作者很懒,什么都没留下…
展开
-
Maximum Product UVA - 11059(枚举入门)
Given a sequence of integers S = f S 1 ;S 2 ;:::;S n g , you should determine what is the value of the maximum positive product involving consecutive terms of S . If you cannot nd a posi...原创 2018-11-25 17:02:14 · 6512 阅读 · 1 评论 -
枚举排列
1~n的全排列: #include <iostream> #include <cstring> #include <cstdio> #include <cstdlib> #include <algorithm> #include <sstream> #include <cmath> #include &原创 2018-11-26 18:41:48 · 6878 阅读 · 0 评论 -
子集生成
增量构造法: #include <iostream> #include <cstring> #include <cstdio> #include <cstdlib> #include <algorithm> #include <sstream> #include <cmath> #include <原创 2018-11-26 21:09:46 · 6283 阅读 · 0 评论 -
八皇后(回溯法)
八皇后问题是一个十分经典的回溯问题,我们将其分析一下可以发现,八皇后问题其实是一个全排列问题,行号代表排列的下标号,列号代表1~n的数字。求得1~n的全排列,回溯找到其中符合要求的情况,这样最多找8!次,即40320次,很小的一个数据量了。在处理是否符合要求时,要注意是否是不同列、不同主对角线、不同副对角线,不需要判断是否是不同行,因为是列的全排列,肯定在不同的行。难点在于对角线的判断,主对角线:...原创 2018-11-27 23:26:03 · 6447 阅读 · 0 评论