摘要:
/*UVa 140 140 - Bandwidth ---数据量比较小,可以直接用next_permutation来枚举全排列,依次计算每一个排序的b(i),求出最小即可 ---在枚举时,注意到在计算某一个排列的带宽过程中,如果发现某两个节点的带宽大于当前总的最小带宽k ---则可以直接剪掉。 */ #define _CRT_SECURE_NO_DEPRECATE #include #inclu... 阅读全文
posted @ 2016-08-30 16:57
曹孟德
阅读(153)
评论(0)
推荐(0)
摘要:
/*UVa129 - Krypton Factor --回溯问题。看例子可知道确定该字符串是按照从左到右依次考虑每个位置,当前位置填不上所有的字符时,需要回溯。 -- */ #define _CRT_SECURE_NO_DEPRECATE #include #include #include #include using namespace std; const int maxn = 1000;... 阅读全文
posted @ 2016-08-30 14:42
曹孟德
阅读(151)
评论(0)
推荐(0)
摘要:
回溯法:在递归构造中,生成和检查的过程可以有机结合起来,从而减少不必要的枚举。把问题分解为若干个步骤求解时,如果当前步骤没有合法选择,则函数将返回上一级的递归调用,该现象称为回溯法。所以递归枚举通常被称为回溯。 8皇后问题:在8*8的棋盘上放置了8个皇后,使得他们互不攻击,每个皇后的攻击范围为同行, 阅读全文
posted @ 2016-08-30 10:45
曹孟德
阅读(395)
评论(0)
推荐(0)
摘要:
#define _CRT_SECURE_NO_DEPRECATE #include #include #include using namespace std; const int maxn = 50; int a[maxn]; bool vis[maxn]; void permutation(int *a,int curr,int n){ if (curr == n){ for (... 阅读全文
posted @ 2016-08-30 10:08
曹孟德
阅读(168)
评论(0)
推荐(0)

浙公网安备 33010602011771号