上一页 1 ··· 67 68 69 70 71 72 73 74 75 ··· 136 下一页
摘要: r排列生成: gen 递归层数d表示正在生成第d个元素。 vis记录是否出现过。 #include#include#includeusing namespace std;int n, r;int A[50], vis[50];//记录第i个元素是否生成过int cnt;int rer;void output(int r){ for(int i = 0; i #include... 阅读全文
posted @ 2014-04-30 16:27 katago 阅读(2986) 评论(0) 推荐(0)
摘要: // 题意: // 输入两个整数N, H,按照字典序输出所有长度为N,恰好包含H个1的01串 // 规模:1#include const int maxn = 20;int N, H, bits[maxn];// 从bits[d]开始确定,已经用了c0个0和c1个1void gen(int d, int c0, int c1) { if(d == N) { if(c1 ... 阅读全文
posted @ 2014-04-28 17:07 katago 阅读(265) 评论(0) 推荐(0)
摘要: 比牌先比牌型,大的牌型大于小的牌型,牌型一般分为10种,从大到小为: 同花大顺(Royal Flush):最高为Ace(一点)的同花顺。 例: 同花顺(Straight Flush):同一花色,顺序的牌。 例: 四条(Four of a Kind,亦称“铁支”、“四张”或“炸弹”):有四张同一点数的牌。 例: 满堂红(Fullhouse,亦称“俘虏”、“骷髅”、“夫... 阅读全文
posted @ 2014-04-25 17:31 katago 阅读(2244) 评论(0) 推荐(0)
摘要: // 题意:有P个LED灯,以及N个字符,要求选出个数最少的LED灯,使得即使只有这些灯正常工作,也能区分出这N个字符 // 题意抽象:输入两个整数P, N以及N行P列的01矩阵,找少的列,能区分所有行 // 规模:P#include#include#include#include#includeusing namespace std;const int P=15;const i... 阅读全文
posted @ 2014-04-25 15:44 katago 阅读(234) 评论(0) 推荐(0)
摘要: Problem G. Birthday Cake Background Lucy and Lily are twins. Today is their birthday. Mother buys a birthday cake for them.Now we put the cake onto a Descartes coordinate. Its center is at (... 阅读全文
posted @ 2014-04-25 11:35 katago 阅读(366) 评论(0) 推荐(0)
摘要: bfs图的时候需要注意判重。 八数码状态数 9!=362880 ,如果用9维的vis,9^9=387420489,会有很大的浪费。 有三种方法来解决空间浪费问题: 1、编码解码 这里用cantor编码 typedef int State[9];const int MAXSTATE = 1000000;State st[MAXSTATE], goal;int dist[MAXSTAT... 阅读全文
posted @ 2014-04-24 16:05 katago 阅读(269) 评论(0) 推荐(0)
摘要: http://zh.wikipedia.org/wiki/康托展开 http://www.nocow.cn/index.php/康托展开 http://blog.sina.com.cn/s/blog_4bf7b6580100l2zs.html http://www.skymoon.biz/?p=86 http://www.cnblogs.com/1-2-3/archive/2011/04/... 阅读全文
posted @ 2014-04-24 15:47 katago 阅读(200) 评论(0) 推荐(0)
摘要: 例7-3 倒水问题。 有装满水的6升的杯子、空的3升杯子和1升杯子,3个杯子中都没有刻度。在不使用其他道具的情况下,是否可以量出4升的水呢? 方法如图7-7所示。 图7-7 倒水问题:一种方法是(6,0,0)→(3,3,0)→(3,2,1)→(4,2,0) 注意:由于没有刻度,用杯子x给杯子y倒水时必须一直持续到把杯子y倒满或者把杯子x倒空,而不能中途停止。 你的任务是解决一般性... 阅读全文
posted @ 2014-04-21 20:30 katago 阅读(826) 评论(0) 推荐(0)
摘要: 通过swap方式生成的全排列并不是字典顺序的: #include#include#include#include#includeusing namespace std;int A[20];int cnt;int recur;void perm(int cur, int n, int *A){ recur++; if(cur==n)//empty { ... 阅读全文
posted @ 2014-04-19 14:22 katago 阅读(198) 评论(0) 推荐(0)
摘要: 1、增量构造法: 一次选出一个元素放到集合中,由于集合中的元素是无序的,所以我们从小到大生成所有元素。每次选择的元素都要比之前的大。 如上图,生成 {1, 2, 3} 的子集过程中的解答树。 共有2^n个节点(8个),每个节点都是解。 2、位向量法 每次有选和不选两种情况 {1 ,2 ,3} 子集的解答数 总共有 1+2+4+ … +2^n= 2^(n+1)... 阅读全文
posted @ 2014-04-17 19:35 katago 阅读(225) 评论(0) 推荐(0)
上一页 1 ··· 67 68 69 70 71 72 73 74 75 ··· 136 下一页