結果

問題 No.269 見栄っ張りの募金活動
ユーザー gom74
提出日時 2020-02-06 00:54:33
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 11 ms / 5,000 ms
コード長 592 bytes
コンパイル時間 1,548 ms
コンパイル使用メモリ 166,664 KB
実行使用メモリ 19,292 KB
最終ジャッジ日時 2024-09-24 08:21:32
合計ジャッジ時間 2,394 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

const int mod = 1e9 + 7;

int main() {
    int N, S, K;
    cin >> N >> S >> K;
    long long dp[N + 1][S + 1];
    memset(dp, 0, sizeof(dp));
    dp[0][0] = 1;
    for (int i = 1; i <= N; ++i) {
        for (int j = 0; j <= S; ++j) {
            if (j >= i) {
                dp[i][j] = (dp[i - 1][j] + dp[i][j - i]) % mod;
            } else {
                dp[i][j] = dp[i - 1][j] % mod;
            }
        }
    }
    int res = N * (N - 1) * K / 2;
    int ans = (S < res) ? 0 : dp[N][S - res];
    cout << ans << endl;

    return 0;
}
0