版权声明: 本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
title: "题解 - [AtCoder ARC110D] Binomial Coefficient is Fun" categories:
Time Limit: 2 sec / Memory Limit: 1024 MB
Score : 600 points
We have a sequence $A$ of $N$ non-negative integers
Compute the sum of $\prod_{i=1}^N\binom{B_i}{A_i}$ over all sequences $B$ of $N$ non-negative integers whose sum is at most $M$, and print it modulo ($10^9+7$)
Here, $\binom{B_i}{A_i}$ , the binomial coefficient, denotes the number of ways to choose $A_i$ objects from $B_i$ objects, and is 0 when $B_i<A_i$
Input is given from Standard Input in the following format:
$N\ M\A_1\ A_2\ ...\ A_N$
Print the sum of $\prod_{i=1}^N\binom{B_i}{A_i}$, modulo ($10^9+7$)
3 5
1 2 1
8
There are four sequences B such that $\prod_{i=1}^N\binom{B_i}{A_i}$ is at least 1:
The sum of these is $1+2+3+2=8$
10 998244353
31 41 59 26 53 58 97 93 23 84
642612171
给定正整数 $n,m$ 和 $a_1,a_2,\dots,a_n$, 求
$$ \sum_{\begin{smallmatrix} b_1,b_2,...,bn>0\\ \sum{i=1}^nbi\leqslant m \end{smallmatrix}}\prod{i=1}^n\binom{b_i}{a_i} $$
不难发现该问题等价于如下问题
给出 $m$ 个相同的小球和 $n$ 个盒子, 盒子编号为 $1,2,...,n$, 将小球放入盒子中, 要求第 $i$ 个盒子至少放 $a_i$ 个球, 接下来给每个盒子中的小球标号, 并分别在第 $i$ 个盒子里取出 $a_i$ 种, 问一共有多少种取法
先取出 $\sum_{i=1}^na_i$ 个球放进盒子里, 此时问题可转化为
将 $m-\sum_{i=1}^nai$ 个相同的球放入 $n+\sum{i=1}^na_i$ 个有编号盒子(允许盒子为空)的方案数 (考虑插空法易得)
所以最终答案即为
$$ {m+n\choose m-\sum_{i=1}^nai}={m+n\choose\sum{i=1}^na_i+n} $$