CF451E.Devu and Flowers
提高+/省选-
通过率:0%
时间限制:4.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Devu wants to decorate his garden with flowers. He has purchased n boxes, where the i-th box contains f__i flowers. All flowers in a single box are of the same color (hence they are indistinguishable). Also, no two boxes have flowers of the same color.
Now Devu wants to select exactly s flowers from the boxes to decorate his garden. Devu would like to know, in how many different ways can he select the flowers from each box? Since this number may be very large, he asks you to find the number modulo (109 + 7).
Devu considers two ways different if there is at least one box from which different number of flowers are selected in these two ways.
Devu 想要用鲜花装饰他的花园。他购买了 n 个盒子,其中第 i 个盒子包含 fi 朵花。同一盒子中的所有花颜色相同(因此彼此不可区分)。此外,任意两个盒子中的花颜色均不相同。
现在,Devu 想要恰好从这些盒子中选出 s 朵花来装饰他的花园。Devu 想知道:他从每个盒子中选花的方式共有多少种?由于该数目可能非常大,他请你计算结果对 109+7 取模的值。
Devu 认为两种方式不同,当且仅当存在至少一个盒子,使得在这两种方式中从该盒子中选出的花朵数量不同。
输入格式
The first line of input contains two space-separated integers n and s (1 ≤ n ≤ 20, 0 ≤ s ≤ 1014).
The second line contains n space-separated integers _f_1, _f_2, ... f__n (0 ≤ f__i ≤ 1012).
输入的第一行包含两个以空格分隔的整数 n 和 s(1 ≤ n ≤ 20,0 ≤ s ≤ 1014)。
第二行包含 n 个以空格分隔的整数 f1, f2, …,fn(0 ≤ fi ≤ 1012)。
输出格式
Output a single integer — the number of ways in which Devu can select the flowers modulo (109 + 7).
输出一个整数——Devu 选择花朵的方案数对 109+7 取模的结果。
输入输出样例
输入#1
2 3 1 3
输出#1
2
输入#2
2 4 2 2
输出#2
1
输入#3
3 5 1 3 2
输出#3
3
说明/提示
Sample 1. There are two ways of selecting 3 flowers: {1, 2} and {0, 3}.
Sample 2. There is only one way of selecting 4 flowers: {2, 2}.
Sample 3. There are three ways of selecting 5 flowers: {1, 2, 2}, {0, 3, 2}, and {1, 3, 1}.
样例 1:选择 3 朵花有两种方式:{1, 2} 和 {0, 3}。
样例 2:选择 4 朵花只有一种方式:{2, 2}。
样例 3:选择 5 朵花有三种方式:{1, 2, 2}、{0, 3, 2} 和 {1, 3, 1}。
输入解题思路,AI测评打分。不知道怎么写?