#include #include using namespace atcoder; //#pragma GCC optimize("O3") using namespace std; #define reps(i,s,n) for(int i = s; i < n; i++) #define rep(i,n) reps(i,0,n) #define Rreps(i,n,e) for(int i = n - 1; i >= e; --i) #define Rrep(i,n) Rreps(i,n,0) #define ALL(a) a.begin(), a.end() using ll = long long; using vec = vector; using mat = vector; ll N,M,H,W,Q,K,A,B; string S; using P = pair; using tp = tuple; const ll INF = (1LL<<61); template bool chmin(T &a, const T b){ if(a > b) {a = b; return true;} else return false; } template bool chmax(T &a, const T b){ if(a < b) {a = b; return true;} else return false; } template void my_printv(std::vector v,bool endline = true){ if(!v.empty()){ for(std::size_t i{}; i; const ll MAX_N = ll(4e+5) + 10; vm fact(MAX_N, mint(1)), fact_inv(MAX_N, mint(1)), n_inv(MAX_N, mint(1)); void makefact(){ reps(i,2,MAX_N) fact[i] = fact[i-1] * mint::raw(i); fact_inv[MAX_N - 1] = fact[MAX_N - 1].inv(); Rreps(i, MAX_N - 1, 1){ fact_inv[i] = fact_inv[i + 1] * mint::raw(i + 1); n_inv[i + 1] = fact[i] * fact_inv[i + 1]; } } mint nCm(ll n, ll m){ if(m < 0) return 0; return fact[n] * fact_inv[n-m] * fact_inv[m]; } mint nCm_inv(ll n, ll m){ return fact[n-m] * fact[m] * fact_inv[n]; } void pr(vector &dp){ rep(i, N + 1){ for(mint m : dp[i]) cout<>N>>mp>>mq>>L; vec a(N); rep(i, N) cin>>a[i]; vector dp(N + 1, vm(mq + 1)); dp[0][0] = 1; rep(i, N){ Rrep(j, N){ vm plus(mq + 1); rep(k, mq) plus[k + 1] = dp[j][k]; rep(k, mq) plus[k + 1] += plus[k]; Rreps(k, mq + 1, a[i]) plus[k] -= plus[k - a[i]]; rep(k, mq + 1) dp[j + 1][k] += plus[k]; } //pr(dp); } mint res; rep(i, N + 1) { rep(j, mq + 1){ int rest_P = mp - (L * i - j); res += dp[i][j] * nCm(N + rest_P - 1, rest_P); } } cout<