結果

問題 No.269 見栄っ張りの募金活動
ユーザー shung11260shung11260
提出日時 2019-11-05 08:28:31
言語 C++11
(gcc 13.3.0)
結果
AC  
実行時間 29 ms / 5,000 ms
コード長 852 bytes
コンパイル時間 847 ms
コンパイル使用メモリ 63,264 KB
実行使用メモリ 19,456 KB
最終ジャッジ日時 2024-09-14 23:59:06
合計ジャッジ時間 1,628 ms
ジャッジサーバーID
(参考情報)
judge6 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>

using namespace std;

const long long int MOD=1e9+7;

int main() {
    int N;
    long long int S, K;
    cin >> N >> S >> K;
    
    long long int M=S-((N-1)*N)/2*K;
    // cout << M << endl;
    if(M<0) {
        cout << 0 << endl;
        return 0;
    }
    vector<vector<long long int> > dp(N+1, vector<long long int>(M+1, 0));
    dp[0][0]=1;
    for(int m=0; m<M+1; m++) {
        for(int n=1; n<N+1; n++) {
            if(m-n>=0) {
                dp[n][m] = (dp[n][m-n] + dp[n-1][m])%MOD;
            } else {
                dp[n][m] = dp[n-1][m]%MOD;
            }
        }
    }
    
    // for(int n=0; n<N+1; n++) {
    //     for(int m=0; m<M+1; m++) {
    //         cout << dp[n][m] << " ";
    //     }
    //     cout << endl;
    // }
    
    cout << dp[N][M] << endl;

    return 0;
    
}
0