bzoj 4710: [Jsoi2011]分特产
来源:互联网 发布:php商城哪个好 编辑:程序博客网 时间:2024/06/02 12:06
题意:
将m种不同特产分给n个人,每种物品a[i]个,每个人多要有至少一个特产。问方案数。
题解:
傻逼题。
假如可以有人没有,那么就是
然后容斥减不合法的就没有了。
code:
#include<cstdio>#include<cstdlib>#include<cstring>#include<iostream>#define LL long long using namespace std;const LL mod=1000000007;LL C[2010][2010],n,m,a[1010];void pre(){ for(LL i=0;i<=2000;i++) { C[i][0]=1; for(LL j=1;j<=i;j++) C[i][j]=(C[i-1][j]+C[i-1][j-1])%mod; }}LL solve(LL x){ LL ans=1; for(LL i=1;i<=m;i++) ans=ans*C[x+a[i]-1][x-1]%mod; return ans;}int main(){ pre(); scanf("%lld %lld",&n,&m); for(LL i=1;i<=m;i++) scanf("%lld",&a[i]); LL ans=0; for(LL i=1;i<=n;i++) { LL tmp=solve(i); if((i&1)==(n&1)) ans=(ans+tmp*C[n][i]%mod)%mod; else ans=(ans-tmp*C[n][i]%mod)%mod; (ans+=mod)%=mod; } printf("%lld",ans);}
阅读全文
1 0
- bzoj 4710 [Jsoi2011]分特产
- bzoj 4710: [Jsoi2011]分特产
- 4710: [Jsoi2011]分特产
- bzoj 4710: [Jsoi2011]分特产 (容斥原理+DP)
- bzoj 4710: [Jsoi2011]分特产 排列组合+容斥原理
- [bzoj4710][JSOI2011]分特产
- BZOJ4710 [Jsoi2011]分特产
- 【JSOI2011】bzoj4710 分特产
- bzoj4710: [Jsoi2011]分特产
- [BZOJ4710]4710: [Jsoi2011]分特产 容斥原理+组合数学
- [BZOJ4710][Jsoi2011]分特产 容斥原理
- [BZOJ4710][Jsoi2011]分特产 容斥原理
- [容斥][排列组合] BZOJ4710 && Jsoi2011.分特产
- bzoj4710 [Jsoi2011]分特产 容斥原理
- BZOJ 4710 分特产 容斥原理
- [BZOJ4710][Jsoi2011]分特产(容斥原理+组合数学)
- [BZOJ4710][JSOI2011]分特产(组合数学+容斥原理)
- 【BZOJ 4710】【JSOI 2011】分特产【计数&容斥】
- 使用FFmpeg把视频转换成JPG格式的图片
- LevelDB源码分析之四:AtomicPointer
- 逻辑运算
- 让你不再害怕指针——C指针详解(经典,非常详细)
- CMake简单使用
- bzoj 4710: [Jsoi2011]分特产
- 在Myeclipse中开发web项目时,servlet的创建和使用中应该注意的问题。
- 秒杀多线程第八篇 经典线程同步 信号量Semaphore
- 蓝牙常用协议
- 正则表达式
- Android实现下拉放大图片,松手自动反弹效果
- pat乙1013
- Andrew Ng's deeplearning Course4Week2 Deep convolutional models(深度卷积网络:实例探究)
- 海量数据实时在线分析Quick BI入门