#include #include using namespace atcoder; #ifdef LOCAL #include #define dbg(...) debug::dbg(#__VA_ARGS__, __VA_ARGS__) #else #define dbg(...) void(0) #endif using namespace std; // #define int long long #define rep(i, a, b) for(int i=static_cast(a), i##_end__=static_cast(b); i < i##_end__; i++) #define rep_r(i, a, b) for(int i=static_cast(a), i##_end__=static_cast(b); i >= i##_end__; i--) #define fore(i, a) for(auto& i: a) #define all(x) std::begin(x), std::end(x) using ll = long long; // __int128; using ull = unsigned long long; template int siz(const C& c) { return static_cast(c.size()); } template constexpr int siz(const T (&)[N]) { return static_cast(N); } template inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } template constexpr T pow2(T x){ return x * x; } template constexpr T divceil(T x, S div){ return (x + div - 1) / div; } constexpr long long INF = 1LL << 60; // 1.15e18 // constexpr int MOD = (int)1e9 + 7; // 分割数 P(n, k) - 自然数 n を k 個の 0 以上の整数の和で表す方法の数 - 漸化式計算 O(nk) // ※「k 個の 1 以上の整数への分割」は P(n-k, k) 通り template struct Partition { vector> P; constexpr Partition(int N, int K) noexcept : P(N + 1, vector(K + 1, 0)) { for (int k = 0; k <= K; ++k) P[0][k] = 1; for (int n = 1; n <= N; ++n) { for (int k = 1; k <= K; ++k) { // 漸化式 // P(n,k)=P(n,k−1)+P(n−k,k) // n を k 個の 0 以上の整数の和として表す方法のうち、 // 分解に 0 を含むものについては、そのうちのどれかの 0 を取り除いてしまうことで、n を k−1 個の 0 以上の整数の和として表す方法に帰着される。よって、P(n,k−1) 通り。 // 分解に 0 を含まない場合は、k 個の整数がすべて 1 以上なので、それぞれ 1 を引くことで n−k を k 個の 0 以上の整数の和として表す方法に帰着される。よって、P(n−k,k) 通り。 P[n][k] = P[n][k - 1] + (n - k >= 0 ? P[n - k][k] : 0); } } } constexpr T get(int n, int k) { if (n < 0 || k < 0) return 0; return P[n][k]; } }; void _main() { int N, S, K; cin >> N >> S >> K; rep(i, 0, N) S -= K * i; if(S < 0){ cout << 0 << endl; return; } using mint = modint1000000007; auto par = Partition(S, N); cout << par.get(S, N).val() << endl; } signed main() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(15); _main(); }