Codeforces Round #258 (Div. 2) E . Devu and Flowers 母函数+公式
来源:互联网 发布:linux 用终端打开文件 编辑:程序博客网 时间:2024/05/16 01:01
题解:http://codeforces.com/blog/entry/13181
#include<stdio.h>#include<string.h>#include<math.h>#include<iostream>#include<algorithm>using namespace std;#define N 55#define ll long long#define inf 0x3f3f3f3fll mod=1e9+7;ll f[22];ll n,s;ll inv(ll a)//求逆元{return a == 1 ? 1 : (long long)(mod - mod / a) * inv(mod % a) % mod;}ll choose(ll m,ll k)求组合数C(m,k){ll ret=1;for(ll i=0;i<k;i++)ret=ret*((m-i)%mod)%mod*inv(i+1)%mod;return ret;}ll go(ll i,ll s)//求解系数{if(s<0) return 0;if(i==n)return choose(n+s-1,n-1);return (go(i+1,s)-go(i+1,s-f[i])+mod)%mod;}int main(){cin>>n>>s;for(int i=0;i<n;i++){cin>>f[i];f[i]++;}cout<<(go(0,s)+mod)%mod<<endl;//system("pause");}
0 0
- Codeforces Round #258 (Div. 2) E . Devu and Flowers 母函数+公式
- Codeforces Round #258 (Div. 2)E. Devu and Flowers
- Codeforces Round #258 (Div. 2) E. Devu and Flowers 隔板法,容斥, Lucas
- Codeforces#258 (Div.2) E - Devu and Flowers 容斥
- Codeforces#258 (Div.2) E - Devu and Flowers
- Codeforces #258 Div.2 E Devu and Flowers
- Codeforces Round #258 (Div. 2)Devu and Flowers 容斥原理
- Codeforces 451 E Devu and Flowers
- codeforces 451 E Devu and Flowers
- [Codeforces 451E] Devu and Flowers (母函数+lucas定理)
- codeforces Devu and Flowers 母函数 容斥 dp
- Codeforces Round #251 (Div. 2) D. Devu and his Brother
- Codeforces Round#251(Div 2)D Devu and his Brother
- Codeforces Round #251 (Div. 2) D Devu and his Brother
- Codeforces Round #251 (Div. 2)-D. Devu and his Brother
- Codeforces 451E Devu and Flowers(容斥原理)
- codeforces 451E Devu and Flowers (容斥原理)
- codeforces 451E. Devu and Flowers 组合数+容斥
- pkg-config for mac 安装
- 【Visual C++】游戏开发笔记之五——游戏画面绘图(二)绘制位图
- NetBeans 8.0创建Java Web时没有web.xml的解决方法
- hdu-1007-Quoit Design
- HDU 1518 Square 搜索
- Codeforces Round #258 (Div. 2) E . Devu and Flowers 母函数+公式
- poj_2240 Bellman-ford算法变形
- 苹果手机里的照片删了怎么恢复
- Storm Topology的并发度
- PPT使用技巧,无论老师还是职员都需要
- getaddrinfo()函数详解
- Handler记录
- JAVA_WEB项目之Spring中使用AOP编程运用到Lucene中实现解耦
- 【小白的java成长系列】——顶级类Object源码分析