結果

問題 No.269 見栄っ張りの募金活動
ユーザー fine
提出日時 2016-04-03 01:18:20
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 4,450 ms / 5,000 ms
コード長 697 bytes
コンパイル時間 1,320 ms
コンパイル使用メモリ 162,396 KB
実行使用メモリ 19,328 KB
最終ジャッジ日時 2024-07-16 01:55:34
合計ジャッジ時間 17,741 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    const long long MOD = 1000000007;
    int n, s, k;
    cin >> n >> s >> k;
    if (s >= n * (n - 1) * k / 2) s -= n * (n - 1) * k / 2;
    else {
        cout << 0 << "\n";
        return 0;
    }
    vector< vector<long long> > dp(n + 1, vector<long long>(s + 1,0)); 
    dp[0][0] = 1;
    for(int i = 1; i <= n; i++) {
        for(int j = 0; j <= s; j++) {
            for(int t = 0; t * (n - i + 1) <= j; t++) {
                dp[i][j] += dp[i - 1][j - (n - i + 1) * t];
                dp[i][j] %= MOD;
            }
        }
    }
    cout << dp[n][s] << "\n";
    return 0;
}
0