
组合数
文章平均质量分 56
wwt9b15bs
这个作者很懒,什么都没留下…
展开
-
【题解】UVA10375 组合数+线性筛+唯一分解定理
题目链接 线性筛出10000以内素数表,求出唯一分解式中各个素数的指数#include<cstdio>#include<cstring>#include<cmath>#define _rep(i,a,b) for(int i=(a);i<=(b);i++)#define _for(i,a,b) for(int i=(a);i&原创 2018-08-12 09:14:13 · 252 阅读 · 0 评论 -
【题解】[牛客OI周赛4-提高组]B.最后的晚餐 组合数+容斥原理
题目链接#include<cstdio>typedef long long ll;const int mod=1e9+7;int n;ll ans=1,a,b,c;int main(){ scanf("%d",&n); if(n==1){puts("0");return 0;} a=1;b=n-2; for(int i=...原创 2018-11-01 17:51:12 · 384 阅读 · 0 评论 -
【题解】洛谷P2822[NOIP2016]组合数问题 组合计数+前缀和
题目链接线性递推组合数,然后求一个前缀和。对着大佬题解改改改一直没对,然后发现m可以大于n……#include<cstdio>const int N=2e3+10;int t,k,n,m;long long C[N][N],sum[N][N];int main(){ //freopen("in.txt","r",stdin); scanf("%d...原创 2018-10-24 17:28:40 · 421 阅读 · 0 评论 -
【题解】[牛客网NOIP赛前集训营-提高组(第五场)]C.串串 组合数
题目链接#include<cstdio>const int N=4e3+10,mod=1e9+7;int a,b,c,d,fac[N],inv[N],ans;int C(int n,int m){ if(n<0||m<0)return 0; return 1ll*fac[n]*inv[m]%mod*inv[n-m]%mod;}int main()...原创 2018-10-31 13:28:51 · 304 阅读 · 0 评论 -
【题解】LibreOJ10206(poj3421) X-factor Chain 多重集的排列数
题目链接题目描述输入正整数 xxx,求 xxx 的大于 111 的因子组成的满足任意前一项都能整除后一项的序列的最大长度,以及满足最大长度的序列的个数。输入格式多组数据,每组数据一行,包含一个正整数 xxx。输出格式对于每组数据,输出序列的最大长度以及满足最大长度的序列的个数。样例样例输入23410100样例输出1 11 12 12 24 6数据范围与提示...原创 2018-09-21 08:20:09 · 361 阅读 · 0 评论 -
【题解】牛客OI周赛1-提高组 B.树 树上倍增+组合计数
链接:https://www.nowcoder.com/acm/contest/199/B来源:牛客网学习了大佬代码。对着这份代码看了一个多小时好像有点点明白。大概就是在这头选两个端点在那头选两个端点更新答案(说了等于没说)。选子树内那一头是不能在同一个子节点的子树内部选两个(会多占一些边),选子树外那头也得把共了边的部分减去,保证最后往上跳之后求出来的路径组合长度是在范围内的。#in...原创 2018-10-02 16:21:25 · 431 阅读 · 0 评论 -
【题解】codeforces451E Devu and Flowers 容斥原理+组合计数
DescriptionDevu wants to decorate his garden with flowers. He has purchased n boxes, where the i-th box contains fi flowers. All flowers in a single box are of the same color (hence they are indis...原创 2018-09-13 06:52:50 · 429 阅读 · 0 评论 -
【题解】洛谷P2480(同bzoj1951)[SDOI2010]古代猪文 组合计数+逆元+快速幂+中国剩余定理+Lucas定理+扩展欧拉定理
题目链接题目背景“在那山的那边海的那边有一群小肥猪。他们活泼又聪明,他们调皮又灵敏。他们自由自在生活在那绿色的大草坪,他们善良勇敢相互都关心……”——选自猪王国民歌很久很久以前,在山的那边海的那边的某片风水宝地曾经存在过一个猪王国。猪王国地理位置偏僻,实施的是适应当时社会的自给自足的庄园经济,很少与外界联系,商贸活动就更少了。因此也很少有其他动物知道这样一个王国。猪王国虽然...原创 2018-09-12 06:23:02 · 303 阅读 · 0 评论 -
【题解】CH3602Counting Swaps 组合计数+快速幂+逆元
题目链接背景https://ipsc.ksp.sk/2016/real/problems/c.htmlJust like yesterday (in problem U of the practice session), Bob is busy, so Alice keeps on playing some single-player games and puzzles. In h...原创 2018-09-12 06:22:58 · 524 阅读 · 0 评论 -
【题解】洛谷P1313(同CH3601)[NOIP2011D2T1]计算系数 组合计数+快速幂+逆元
题目链接 挺无脑一题,根据二项式定理乱搞就好#include&lt;cstdio&gt;typedef long long ll;ll a,b,n,k,m,jck=1,ans=1,jcn=1,jck_n=1;const int mod=10007;ll qpow(ll a,ll b){ ll ret=1; for(;b;b&gt;&gt;=1) {...原创 2018-09-12 06:22:51 · 205 阅读 · 0 评论 -
【题解】洛谷P4996[【LGR-055】洛谷11月月赛]C.咕咕咕 组合数
题目链接#include&lt;cstdio&gt;const int mod=998244353;typedef long long ll;inline int read(){ int s=0,f=0;char ch=getchar(); while(ch&lt;'0'||ch&gt;'9')f|=ch=='-',ch=getchar(); while(ch&g...原创 2018-11-05 14:59:03 · 374 阅读 · 0 评论