随笔分类 - 数学—组合数学
摘要:题目链接DescriptionYaroslav thinks that two stringssandw, consisting of digits and having lengthnare non-comparable if there are two numbers,iandj(1 ≤ i, ...
阅读全文
摘要:题目链接下午比赛的时候没有想出来,其实就是int型的数分为30个位,然后按照位来排列枚举。题意:求n个数里面,取i个数异或的所有组合的和,i取1~n分析:将n个数拆成30位2进制,由于每个二进制位异或后相加和原来的数异或相加是一样的,所以只需要对每一位累加计算,用组合数学取数就行了,奇数个异或得1,...
阅读全文
摘要:题目:http://poj.org/problem?id=2409题意:用k种不同的颜色给长度为n的项链染色网上大神的题解:1.旋转置换:一个有n个旋转置换,依次为旋转0,1,2,```n-1。对每一个旋转置换,它循环分解之后得到的循环因子个数为gcd(n,i).2.翻转置换:分奇偶讨论。奇数的时候...
阅读全文
posted @ 2014-02-10 23:30
水门
摘要:题目:http://poj.org/problem?id=1942题意:给定一个矩形网格的长m和高n,其中m和n都是unsigned int32类型,一格代表一个单位,就是一步,求从左下角到右上角有多少种走法,每步只能向上或者向右走题解:就是 上和 右的排列。用c(m,n)=n!/m!*(n-m)!;最重要的是算阶乘。 1 #include 2 #include 3 #include 4 using namespace std; 5 6 unsigned comb(unsigned m,unsigned n) 7 { 8 unsigned a,b; 9 double cnt=...
阅读全文
摘要:题目:http://poj.org/problem?id=1850题意:按给定的规则给字母编号。一个很简单的题目,但是却做了好久。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。 1 #include 2 #include 3 #include 4 using namespace std; 5 int c[30][30]; 6 void init()//用杨辉三角的方法求组合数,C(n,m) 7 { 8 int i,j; 9 for(i=0; i>s;21 22 k=strlen(s);23 for(i=0; ...
阅读全文

浙公网安备 33010602011771号