当前位置:网站首页>Rong Tui [jsoi2011] special products
Rong Tui [jsoi2011] special products
2022-07-20 14:56:00 【LauJiYeoung】
Description
JYY Led the team to a number of ACM/ICPC match , Brought back a lot of local products , To the students in the lab .
JYY Want to know , Give these specialties to N A classmate , How many different ways are there ? Of course ,JYY Don't want to be
He Yiyi felt lost because he didn't get the specialty , So every student must get at least one specialty .
for example ,JYY brought 2 Bag fried dough twist and 1 Bag steamed stuffed bun , among A and B Two students , So there is 4 Different species
Distribution method :
A: Hemp flowers ,B: Hemp flowers 、 Steamed stuffed bun
A: Hemp flowers 、 Hemp flowers ,B: Steamed stuffed bun
A: Steamed stuffed bun ,B: Hemp flowers 、 Hemp flowers
A: Hemp flowers 、 Steamed stuffed bun ,B: Hemp flowers
Input
The first line of input data is the number of students N And the number of specialties M.
The second line contains M It's an integer , Indicates the quantity of each specialty .
N, M No more than 1000, The quantity of each specialty does not exceed 1000
Output
Output one line , Total number of different distribution schemes . Because the output can be huge , You just need to output the final result
MOD 1,000,000,007 Just the value of .
Sample Input
5 4
1 3 3 5
Sample Output
384835
A very good content exclusion question
The original idea was to divide by one arrangement, but in fact, it can't
Find that the specialty itself is independent
So consider it alone
It's no good subtracting one from any score ...
∏ i = 1 m C A i + n − 1 n − 1 \prod_{i=1}^mC_{A_i+n-1}^{n-1} ∏i=1mCAi+n−1n−1 It's all without consideration
It is actually this thing after tolerance and exclusion
∑ i = 0 n ( − 1 ) i C n i ∏ j = 1 m C A i + n − i − 1 n − i − 1 \sum_{i=0}^n(-1)^iC_n^i\prod_{j=1}^mC_{A_i+n-i-1}^{n-i-1} ∑i=0n(−1)iCni∏j=1mCAi+n−i−1n−i−1
/**************************************************************
Problem: 4710
User: Leo_JAM
Language: C++
Result: Accepted
Time:676 ms
Memory:50360 kb
****************************************************************/
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
typedef int INT;
#define int long long
const int mod=1e9+7;
int C[2200][2200];
int F[1200][1200];
void Pre(){
C[0][0]=1;
for(int i=1;i<=2000;++i){
C[i][0]=1;
for(int j=1;j<=i;++j){
C[i][j]=(C[i-1][j-1]+C[i-1][j])%mod;
}
}
}
int ans=0;
int n,m;
int G[1200];
INT main(){
Pre();
scanf("%lld%lld",&n,&m);
for(int i=1;i<=m;++i)scanf("%lld",&G[i]);
int cur=-1;
for(int i=0;i<n;++i){
cur=cur*(-1);
int now=cur;
for(int j=1;j<=m;++j){
now=(now*C[G[j]+n-i-1][n-i-1]%mod);
}
now=now*C[n][i]%mod;
ans=(ans+now)%mod;
}
cout<<(ans+mod)%mod;
return 0;
}
边栏推荐
猜你喜欢
随机推荐
Sail soft report dataset SQL
Redis支撐秒殺場景的關鍵技術和實踐都有哪些?
ACL 2022 | text to table: a new information extraction task
云图说丨数字资产链:您的数字资产产权保护神
读写分离备机备份报错
【云原生】Nacos中的事件发布与订阅--观察者模式
使用Masonry实现控件(包括UITableView)根据内容进行宽度自适应和高度自适应
Is there a function similar to ifnull in flinksql?
爱线段树的好孩子【九校2D1T3】优美序列
Oracle的$sqlarea 是不是无法查出来这些SQL是那台主机执行的?
【云驻共创】华为云助力加速构建企业数据资产和数据治理生产线
Motor control -- Realization and derivation of SVPWM sector judgment
C#/VB. Net to add multi line text watermark to word document
剑指offer题库总结(二)之字符串(C语言版本)
SAP 实施项目中涉及到编程方式操作 Excel 的几种场景介绍
开始菜单没有数据库快捷工具图标
[论文阅读] Unpaired Image-To-Image Translation Using Cycle-Consistent Adversarial Networks
LINK : fatal error LNK1104: 无法打开文件“ucrtd.lib” 解决方法 Visual Studio
C#/VB.NET 添加多行文本水印到Word文档
Difference Between Accuracy and Precision