結果

問題 No.269 見栄っ張りの募金活動
ユーザー Ai3Shota
提出日時 2018-08-16 14:02:31
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 68 ms / 5,000 ms
コード長 554 bytes
コンパイル時間 1,330 ms
コンパイル使用メモリ 162,496 KB
実行使用メモリ 20,224 KB
最終ジャッジ日時 2024-07-16 02:07:05
合計ジャッジ時間 2,675 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
typedef long long ll;

int N, S, K;
vector<vector<ll>> dp(20001, vector<ll>(101, 0));

ll p(int s = S, int n = N){
    
    if(n == 0) return !s;
    
    ll& res = dp[s][n];
    if(res) return res;
    
    res += p(s, n - 1);
    res %= MOD;
    res += (s < n) ? 0 : p(s - n, n);
    res %= MOD;
    
    return res;
}

int main(void){
    
    cin >> N >> S >> K;
    S -= N * (N - 1) / 2 * K;
    
    if(S < 0) cout << 0 << endl;
    else cout << p() << endl;
    
    return 0;
}
0