BZOJ 3027: [Ceoi2004]Sweet
容斥
#include<cstdio>
using namespace std;
int a,b,n,m[15];
long long ans=0,mod=2004;
long long C(int n,int m){
long long ans=1;
for (int i=n; i>=n-m+1; i--) ans=ans*i%mod;
return ans;
}
void dfs(int t,int lim,int cas){
if (lim<0) return;
if (t>n){
ans+=1ll*cas*C(lim+n,n);
ans%=mod;
ans+=mod;
ans%=mod;
return;
}
dfs(t+1,lim,cas);
dfs(t+1,lim-m[t]-1,-cas);
}
long long solve(int lim){
ans=0;
dfs(1,lim,1);
for (int i=1; i<=n; i++) ans/=i;
return ans;
}
int main(){
scanf("%d%d%d",&n,&a,&b);
for (int i=1; i<=n; i++) scanf("%d",&m[i]);
for (int i=1; i<=n; i++) mod*=i;
printf("%lld\n",(solve(b)-solve(a-1)+2004)%2004);
return 0;
}
BZOJ 3027: [Ceoi2004]Sweet的更多相关文章
- bzoj 3027: [Ceoi2004]Sweet (生成函数)
题目传送门:https://www.lydsy.com/JudgeOnline/problem.php?id=3027. 题目大意:有$n$种数,每种有$C_i$个,问你在这些数中取出$[l,r]$个 ...
- bzoj 3027 [Ceoi2004]Sweet——生成函数
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=3027 化式子到 ( \mul_{i=1}^{n}(1-x^(m[i]+1)) ) / (1- ...
- bzoj 3027 [Ceoi2004] Sweet —— 生成函数
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=3027 就是 (1+x+x2+...+xm[i]) 乘起来: 原来想和背包一样做,然而时限很短 ...
- bzoj 3027: [Ceoi2004]Sweet【生成函数+组合数学】
首先根据生成函数的套路,这个可以写成: \[ \prod_{i=1}^{n}(1+x^1+x^2+...+x^{c[i]}) \] 然后化简 \[ =\prod_{i=1}^{n}\frac{1-x^ ...
- 【BZOJ 3027】 3027: [Ceoi2004]Sweet (容斥原理+组合计数)
3027: [Ceoi2004]Sweet Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 71 Solved: 34 Description John ...
- [BZOJ3027][Ceoi2004]Sweet 容斥+组合数
3027: [Ceoi2004]Sweet Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 135 Solved: 66[Submit][Status] ...
- BZOJ3027 - [CEOI2004]Sweet
Portal Description 给出\(n(n\leq10),a,b(a,b\leq10^7)\)与\(\{c_n\}(c_i\leq10^6)\),求使得\(\sum_{i=1}^n x_i ...
- BZOJ 3027 Sweets 生成函数,容斥
Description John得到了n罐糖果.不同的糖果罐,糖果的种类不同(即同一个糖果罐里的糖果种类是相同的,不同的糖果罐里的糖果的种类是不同的).第i个糖果罐里有 mi个糖果.John决定吃掉一 ...
- 2018.12.30 bzoj3027: [Ceoi2004]Sweet(生成函数+搜索)
传送门 生成函数好题. 题意简述:给出n个盒子,第iii个盒子里有mim_imi颗相同的糖(但不同盒子中的糖不相同),问有多少种选法可以从各盒子中选出数量在[a,b][a,b][a,b]之间的糖果. ...
随机推荐
- EF--Model First
Model First先设计Model对象,再由对象生成数据库. 1.新建控制台项目,名称ModelFirst,确定. 2.点击选中项目,右键-->添加-->新建项目--选择数据模板--& ...
- jq 操作select
添加option $("#ID option").each(function(){if($(this).val()==111){$(this).remove();}}); 移除op ...
- 青石B2C商城
平台: Windows 类型: 虚拟机镜像 软件包: azure commercial ecbluestone ecommerce ecommerce solution 服务优惠价: 按服务商许可协议 ...
- jQuery-prepend、append、before、after的区别
举例说明,原始html代码如下: <ol> <li>List item 1</li> <li>List item 2</li> <li ...
- 音乐代码 (DNF天空之城、欢乐颂)。
太感人了 DNF天空之城 #include <cstdio> #include <windows.h> #define qdo 262 #define qre 294 #def ...
- 什么是 pwd
pwd print work directory, 指linux terminal的当前目录 $ pwd
- zendstudio 汉化
http://archive.eclipse.org/technology/babel/index.php http://www.eclipse.org/babel/downloads.php 注册码 ...
- IOS NSThread 线程间通信
@interface HMViewController () @property (weak, nonatomic) IBOutlet UIImageView *imageView; @end @im ...
- C. Tanya and Toys_模拟
C. Tanya and Toys time limit per test 1 second memory limit per test 256 megabytes input standard in ...
- python 面向对象(一)--类(class)和实例(Instance)
面向对象最重要的概念就是类(Class)和实例(Instance),必须牢记类是抽象的模板,比如Student类,而实例是根据类创建出来的一个个具体的“对象”,每个对象都拥有相同的方法,但各自的数据可 ...