
组合数学
文章平均质量分 68
BraketBN
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
【BZOJ2886】最短路【组合数】
【题目链接】 同【BZOJ3260的题解】 /* Pigonometry */ #include #include using namespace std; typedef unsigned long long ULL; typedef long long LL; const ULL p = 1000000007; void exgcd(ULL a, ULL b, LL &x,原创 2016-04-02 09:57:05 · 643 阅读 · 0 评论 -
【BZOJ2445】最大团【推公式】【中国剩余定理】【扩展Lucas】
【题目链接】 公式为: 设 ans = ∑(n! / ((d!)^(n/d)*(n/d)!)) 则答案为m ^ ans 证明: 考虑现在有d * k个点,d代表每个团的点数,那么k就是个数了,记方案数为Ak。 然后现在又来了d个点,记方案数为Ak+1。(即现在有n = d * (k + 1)个点) 我们选择一个点,让这个点与其他的d - 1个点组成团,方案数为C(d *原创 2016-05-30 07:54:07 · 1072 阅读 · 0 评论 -
【CodeChef-CSEQ】Count Sequences【Lucas定理】
【题目链接】 答案为C(n + R - L + 1, n) - 1。 大体推导过程是固定长度,然后隔板法,然后对长度求和。 暴力算组合数那里,要判断n /* Pigonometry */ #include #include #include using namespace std; typedef unsigned long long ULL; const int原创 2016-04-20 23:05:01 · 536 阅读 · 0 评论 -
【BZOJ3142】[Hnoi2013]数列【组合数学】
【题目链接】 【thy_asdf的题解】 /* Telekinetic Forest Guard */ #include #include #include using namespace std; typedef long long LL; LL n, k, m, p; inline LL qpow(LL a, LL n) { LL res = 1; for(; n原创 2016-05-27 16:57:57 · 509 阅读 · 0 评论 -
【BZOJ3656】异或【扩展Lucas】【线性无关】
因为新数列中的数线性无关,所以答案就是C(n, k) % p,因为p比较小,写个扩展Lucas就好了。 证明一下线性无关: 首先有两个引理: 定理1:一个n×n的矩阵A是非奇异的充要条件为 A的行列式不等于0。 定理2:令x1, x2, ..., xn为R^n中的n个向量,并令X = (x1, ..., xn)。向量x1, x2, ..., xn线性无关的充要条件是X原创 2016-02-26 19:46:53 · 1486 阅读 · 0 评论 -
【BZOJ2142】礼物【扩展Lucas】
【题目链接】 原来那个板有问题...重新写了下。 把分解质因数写挂了,WA了一次... /* Telekinetic Forest Guard */ #include #include #include using namespace std; typedef long long LL; const int maxn = 10; LL w[maxn]; inlin原创 2016-05-26 21:37:29 · 553 阅读 · 0 评论 -
【BZOJ1856】[Scoi2010]字符串【组合数】【神题】
【题目链接】 太神了【将狼踩尽的题解】 /* Telekinetic Forest Guard */ #include #include using namespace std; typedef long long LL; const int maxn = 2000001, p = 20100403; int n, m, fact[maxn]; inline int mul(原创 2016-05-13 21:53:40 · 839 阅读 · 0 评论 -
【BZOJ2729】[HNOI2012]排队【组合数学】
【题目链接】 还是python好用 【大爷的题解】 def A(n): res = 1 for i in range(1, n + 1): res *= i return res def C(n, m): if n < m: return 0 return A(n) // A(m) // A(n - m) n, m = [int(i) for i in raw_inpu原创 2016-05-26 17:24:04 · 451 阅读 · 0 评论 -
【BZOJ4403】序列统计【Lucas定理】
【题目链接】 同【CodeChef-CSEQ的题解】 /* Telekinetic Forest Guard */ #include #include #include using namespace std; typedef unsigned long long ULL; const int maxn = 1000505; const ULL p = 1000003; ULL原创 2016-05-02 21:22:03 · 533 阅读 · 0 评论 -
【BZOJ3260】跳【组合数】
设m 所以求出组合数就好了... 发现n * m最大为10^12,那么m最大为10^6。 将组合数用阶乘形式展开,为 (n + m + 1)! / n! / (m + 1)!。 将前两项约掉,得到 (n + 1) * (n + 2) * ... * (n + m + 1) / (m + 1)! 分子有m项,分母有m项,所以可以O(m)求出来。 因为有inv(原创 2016-02-28 20:14:48 · 923 阅读 · 0 评论 -
【BZOJ3659】Which Dreamed It【有向图欧拉回路计数】【matrix tree定理】【BEST定理】【高斯消元】
【题目链接】 定理题... /* Think Thank Thunk */ #include #include #include using namespace std; typedef long long LL; const int maxn = 105, p = 1000003; int n, fact[200005], A[maxn][maxn], du[maxn];原创 2016-07-18 15:19:12 · 2453 阅读 · 0 评论