![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
组合数学
文章平均质量分 79
LB_莫贺延碛
没智商,没毅力,仅仅有一点点运气。
努力向各位前辈大牛学习。
展开
-
字典序生成下一排列组合 poj 1146水
#include #include #include #include #include #include using namespace std; const int maxn = 50 + 10; char str[maxn]; int len; bool solve() { len = strlen(str); int i = len - 1; while (i >原创 2015-03-13 19:07:32 · 420 阅读 · 0 评论 -
排列组合计数 水poj2249 poj1306
都是简单的排列组合公式的实现,注意有时不合适的计算可能会产生溢出 poj2249: #include #include #include using namespace std; typedef long long int64; int64 solution(int64 n, int64 k) { if (k > n / 2) k = n - k; int64 a = 1,原创 2015-03-13 19:35:38 · 549 阅读 · 0 评论 -
莫比乌斯反演
转自:http://blog.csdn.net/acdreamers/article/details/8542292 莫比乌斯反演在数论中占有重要的地位,许多情况下能大大简化运算。那么我们先来认识莫比乌斯反演公式。 定理:和是定义在非负整数集合上的两个函数,并且满足条件,那么我们得到结论 在上面的公式中有一个函数,它的定义如下: (1)若,转载 2016-10-31 22:00:14 · 321 阅读 · 0 评论 -
组合数学之卡特兰数
卡特兰数: 1 通项公式:h(n)=C(n,2n)/(n+1)=(2n)!/((n!)*(n+1)!) 2递推公式:h(n)=((4*n-2)/(n+1))*h(n-1); h(n)=h(0)*h(n-1)+h(1)*h(n-2)+...+h(n-1)*h(0). 3前几项为:h(0)=1,h(1)=1,h(2)=2,h(3)=5,h(4)=14,h(5)=42,...... 4应用场转载 2015-03-13 19:00:18 · 9355 阅读 · 0 评论 -
卡特兰数应用--n个元素的出栈顺序与从(0,0)到(n,n)不穿过对角线的方法数
1.出栈顺序方法数: hdoj1023 求出栈序列,比如1,2,3,出栈序列为3 2 1,1 2 3,1 3 2,2 1 3,2 3 1,一共5种 第一种思路: 我们把入栈看做1,出栈看做0,那么入栈出栈看做一系列的1010。。。,但是必须保证从左往右 看的时候1必须多余0,这个是卡塔兰数的第二个应用,种数为:C(n,2n)-C(n+1,2n). 粗略这样理解:我们从2n个原创 2016-11-29 11:57:43 · 4684 阅读 · 0 评论