#include<cstdio> #include<iostream> #include<algorithm> #define LL long long usingnamespace std; constint MAXN = 25; constint Mod = 1000000007;
LL n, m, a[MAXN], inv[MAXN], ans;
LL qpow(LL x, LL y){ LL res = 1; while (y) { if (y & 1) res = res * x % Mod; x = x * x % Mod; y >>= 1; } return res; }
LL C(LL x, LL y){
if (y > x) return0;
y = x - y; LL res = 1ll; for (LL i = y + 1ll; i <= x; i++) { res = (res * (i % Mod)) % Mod; } for (int i = 1ll; i <= x - y; i++) { res = res * inv[i] % Mod; }
return res; }
intmain(){
inv[0] = 1; for (int i = 1; i <= 20; i++) { inv[i] = qpow(i, Mod - 2); }
scanf("%lld %lld", &n, &m); for (int i = 1; i <= n; i++) { scanf("%lld", &a[i]); }
for (int i = 0, sta = 1, cnt = 0; i < (1 << n); i++, sta = 1, cnt = 0) {
LL tot = 0; for (int j = 1; j <= n; j++) if ((1 << j - 1) & i) { cnt++; tot += a[j] + 1; }
if (cnt & 1) sta = -1;
ans = (ans + sta * C(n + m - 1 - tot, n - 1) % Mod + Mod) % Mod;
// printf("%d %lld %lld\n", cnt, ans, sta * C(n + m - 1 - tot, n - 1));
}
printf("%lld\n", ans);
return0; }
The End
「Ô mon âme, n'aspire pas à la vie immortelle, mais épuise le champ du possible.」