codeforces451E Devu and Flowers题解

Devu用不同颜色的花朵装饰花园,每个箱子内花朵颜色各异。他需要从n个箱子中选取s朵花,计算不同选法的数量模10^9+7。本文介绍了问题的输入输出格式,并提供了分析和解题代码。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值