思路:不难联想到是组合数学那一类题目偏多,给你m种球,每个有
a
i
a_i
ai个球,要求放入
n
n
n个盒子里面,求盒子中都有球的方案。 浓浓的组合数学味道,可惜我写的不多,滚去看题解了 考虑一下补集转换,先求允许空集的方案,再减去盒子中包含空盒的方案. 奉上笔记一页,供大家参考思路.
/*
Stairs upon the temple
I climb and I crawl in
People travel millions of miles just to see it
But they never conquer this way
*/
#include
using namespace std;
const int maxn = 1000+5;
const int INF = 1e9+7;
typedef long long ll;
typedef pair pii;
#define all(a) (a).begin(), (a).end()
#define pb(a) push_back(a)
vector G[maxn];
ll mod = 1e9+7;
ll pw(ll a,ll b){
ll ans = 1;a%=mod;
while(b){
if(b&1) ans=ans*a%mod;
b>>=1;a=a*a%mod;
}
return ans%mod;
}
ll inv(ll a){
return pw(a,mod-2);
}
ll fac[maxn*2];
ll C(ll n,ll m){
return fac[n]*inv(fac[m])%mod*inv(fac[n-m])%mod;
}
int a[maxn];
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
fac[0] =1;
for(int i=1;i>n>>m;
for(int i=1;i>a[i];
ll ans = 0;
for(int i=0;i
关注
打赏
最近更新
- 深拷贝和浅拷贝的区别(重点)
- 【Vue】走进Vue框架世界
- 【云服务器】项目部署—搭建网站—vue电商后台管理系统
- 【React介绍】 一文带你深入React
- 【React】React组件实例的三大属性之state,props,refs(你学废了吗)
- 【脚手架VueCLI】从零开始,创建一个VUE项目
- 【React】深入理解React组件生命周期----图文详解(含代码)
- 【React】DOM的Diffing算法是什么?以及DOM中key的作用----经典面试题
- 【React】1_使用React脚手架创建项目步骤--------详解(含项目结构说明)
- 【React】2_如何使用react脚手架写一个简单的页面?