usingnamespace std; typedef pair<int,int> PII; typedeflonglong LL; constint N=1010,mod=1e9+7; LL down=1,n,m; LL A[21]; LL res,ans; intqmi(int a, int k, int p) { int res = 1; while (k) { if (k & 1) res = (LL)res * a % p; a = (LL)a * a % p; k >>= 1; } return res; }
intC(LL a, LL b) { if (a < b) return0; int up = 1; for (LL i = a; i > a - b; i -- ) up = i % mod * up % mod; return (LL)up * down % mod; }
res=0; for(int i =0;i<1<<n;i++){ LL x = m+n-1,y=n-1; int sign=1; for(int j=0;j<n;j++){ if(i>>j&1){ sign*=-1; x -= A[j]+1; if(x<0) break; } } res = (res+C(x,y)*sign)%mod; }