没sa可suo的,sui题一道……
#include <bits/stdc++.h>using namespace std;#define maxn 3000#define mod 1000000007#define int long longint n, m, ans, a[maxn], C[maxn][maxn];int read(){ ???int x = 0, k = 1; ???char c; c = getchar(); ???while(c < ‘0‘ || c > ‘9‘) { if(c == ‘-‘) k = -1; c = getchar(); } ???while(c >= ‘0‘ && c <= ‘9‘) x = x * 10 + c - ‘0‘, c = getchar(); ???return x * k;}void Pre(){ ???for(int i = 0; i < maxn; i ++) C[i][0] = 1; ???for(int i = 1; i < maxn; i ++) ???????for(int j = 1; j < maxn; j ++) ???????????C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % mod;}int Up(int &x, int y) { x = (x + y) % mod; }int Get(int x){ ???int ret = 1; ???for(int i = 1; i <= m; i ++) ????????ret = ret * C[n - x + a[i] - 1][n - x - 1] % mod; ???return ret;}signed main(){ ???n = read(), m = read(); Pre(); ???for(int i = 1; i <= m; i ++) a[i] = read(); ???for(int i = 0; i <= n; i ++) ????{ ???????int t = C[n][i] * Get(i) % mod; ???????Up(ans, (i & 1) ? -t : t); ???} ???printf("%lld\n", (ans + mod) % mod); ???return 0;}
【题解】JSOI2011分特产
原文地址:https://www.cnblogs.com/twilight-sx/p/10158736.html