#include #include #include #include #include #include #include #include #include #include using namespace std; #define int long long int MOD = 1000000007; template struct comb_util { std::array fc, ifc; comb_util() { fc[0] = 1; for (int i = 1; i <= N; i++) fc[i] = fc[i - 1] * i % MOD; ifc[N] = inv(fc[N]); for (int i = N - 1; i >= 0; i--) ifc[i] = ifc[i + 1] * (i + 1) % MOD; } Int fact(Int n) { return fc[n]; } Int inv_fact(Int n) { return ifc[n]; } Int inv(Int n) { return pow(n, MOD - 2); } Int pow(Int n, Int a) { Int res = 1, exp = n; for (; a; a /= 2) { if (a & 1) res = res * exp % MOD; exp = exp * exp % MOD; } return res; } Int perm(Int n, Int r) { if (r < 0 || n < r) return 0; else return fc[n] * ifc[n - r] % MOD; } Int binom(Int n, Int r) { if (n < 0 || r < 0 || n < r) return 0; return fc[n] * ifc[r] % MOD * ifc[n - r] % MOD; } Int homo(Int n, Int r) { if (n < 0 || r < 0) return 0; return r == 0 ? 1 : binom(n + r - 1, r); } }; using comb = comb_util; comb cb; inline int add(int u, int v) { u += v; if (u >= MOD) u -= MOD; return u; } inline int sub(int u, int v) { u -= v; if (u < 0) u += MOD; return u; } inline int mul(int u, int v) { return (long long)u * v % MOD; } //0<=Ai> N >> M >> D1 >> D2; int res = solve(N + 1, M - (N - 1) * D1 - 1, D2 - D1 + 1); cout << res << endl; }