摘要: Problem description:Please list all of the subsets of a known set including the empty set.My idea: one thinking of the algorithm backtracking is to generate a tree of subset and the condition of an element in the super set for a subset is either on or off.Hence we can specialize the subset tree to a 阅读全文
posted @ 2013-01-03 20:30 NeilHappy 阅读(206) 评论(0) 推荐(0)
摘要: 问题描述:列出一个集合的所有子集,包括空子集合。 我的思路:回溯法的一种思路就是生成一颗子集树,而一个集合中的元素,要么存在于子集中,要么不存在,所以这又特殊化成一颗二叉树了。每当到达二叉树的底端时,就打印一次。很容易写出如下的代码: 1 #include <stdio.h> 2 #define MAX 1000 3 4 int n=3; //the number of the set elements 5 int set[MAX]={1,2,3}; 6 int count=0;//the number of the subset. 7 8 void DFS(int level.. 阅读全文
posted @ 2013-01-03 20:10 NeilHappy 阅读(222) 评论(0) 推荐(0)
摘要: 先用这个数学公式生成器生成公式的图片,然后在将该img的style属性改成 style="padding:0px;border: none;margin:0px;vertical-align: bottom;" 插入到网页中就可以了。 阅读全文
posted @ 2013-01-03 16:13 NeilHappy 阅读(2024) 评论(1) 推荐(1)
摘要: Problem description:When we calculate for prime numbers with a sieve method,we delete so many numbers which is not necessary repeatly.For instance,there is a number which consists of 3x7x17x23,and we delete it when we delete the multiples of 3 as we delete the same number when we delete the multiple 阅读全文
posted @ 2013-01-03 15:57 NeilHappy 阅读(282) 评论(0) 推荐(0)
摘要: Problem description:Calculate the prime numbers with a sieve method.There is amagical sieve that can remove all the multiple of the number i.Please calculate the prime numbers at a range from 2 to N by this way.There is a requirement that you should not use multiplication and division.You can only u 阅读全文
posted @ 2013-01-03 11:57 NeilHappy 阅读(327) 评论(0) 推荐(0)