結果

問題 No.269 見栄っ張りの募金活動
ユーザー 4batakosan
提出日時 2019-06-22 11:55:25
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 23 ms / 5,000 ms
コード長 870 bytes
コンパイル時間 1,044 ms
コンパイル使用メモリ 98,216 KB
実行使用メモリ 19,456 KB
最終ジャッジ日時 2024-12-26 08:44:20
合計ジャッジ時間 2,072 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <chrono>

#define MOD (int64_t)(1e+9 + 7)

using namespace std;

int main(int argc, const char * argv[]) {
    
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, s, k; cin >> n >> s >> k;
    
    vector<vector<int64_t>> dp(n + 1, vector<int64_t>(s + 1, 0));
    
    dp[0][0] = 1;
    
    for (int i = 0; i < n; i++) {
        for (int j = 0; j <= s; j++) {
            if (j >= k * i) {
                dp[i + 1][j] += dp[i][j - k * i];
                dp[i + 1][j] %= MOD;
            }
            if (j >= i + 1) {
                dp[i + 1][j] += dp[i + 1][j - i - 1];
                dp[i + 1][j] %= MOD;
            }
        }
    }
    
    cout << dp[n][s] % MOD << endl;
    
    return 0;
}
0