CF451E Devu and Flowers题解
文章目录
前言
一、题面&输入输出
题面
英文:
Devu wants to decorate his garden with flowers. He has purchased nn boxes, where the ii -th box contains f_{i}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 ss 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 (10^{9}+7)(10 9+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想要知道,总共有多少种方式从这些箱子里取出这么多的花?因为结果有可能会很大,结果需要对1000000007取模。 Devu认为至少有一个箱子中选择的花的数量不同才是两种不同的方案。**
输入输出:
输入格式:
第一行包含两个用空格分开的整数n和s 第二行包含n个用空格分开的整数fi
输出格式:
输出一个整数,Devu的方案数对1000000007取模
1≤N≤20,0≤M≤1014,0≤ci≤1012
二、分析&代码
代码如下:
#include<bits/stdc++.h>
using namespace std;
const int mod=1000000007;
long long a[50],m,ans=0;
int inv[50],n;
int power(int a,int b