結果

問題 No.269 見栄っ張りの募金活動
ユーザー ShibuyapShibuyap
提出日時 2019-10-29 14:33:48
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 3,784 ms / 5,000 ms
コード長 1,156 bytes
コンパイル時間 1,382 ms
コンパイル使用メモリ 165,496 KB
実行使用メモリ 19,720 KB
最終ジャッジ日時 2023-10-12 23:21:45
合計ジャッジ時間 13,732 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 2 ms
4,352 KB
testcase_03 AC 11 ms
6,032 KB
testcase_04 AC 2,520 ms
9,436 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
5,732 KB
testcase_07 AC 3,784 ms
19,720 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 1 ms
4,348 KB
testcase_11 AC 1,048 ms
4,596 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 502 ms
6,340 KB
testcase_14 AC 453 ms
4,352 KB
testcase_15 AC 694 ms
6,556 KB
testcase_16 AC 2 ms
4,348 KB
testcase_17 AC 1 ms
4,352 KB
testcase_18 AC 792 ms
10,560 KB
testcase_19 AC 244 ms
6,692 KB
testcase_20 AC 145 ms
4,352 KB
testcase_21 AC 522 ms
4,352 KB
testcase_22 AC 174 ms
5,960 KB
testcase_23 AC 5 ms
5,520 KB
testcase_24 AC 397 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 105
#define MAX_S 20005

ll dp[MAX_N][MAX_S];

int main() {
    int n, s, k;
    cin >> n >> s >> k;
    s -= (n - 1) * n / 2 * k;

    if(s < 0){
        cout << '0' << endl;
        return 0;
    }

    if(n == 1){
        cout << '1' << endl;
        return 0;
    }

    ll ans = 0;
    ll MOD = 1e9+7;

    drep(i,n){
        if(i == n - 1){
            rep(j,s+1){
                dp[i][j] = 1;
            }
            continue;
        }
        rep(j,s+1){
            rep(l, s+1){
                if(j - l*(n-i) < 0)break;
                dp[i][j] += dp[i+1][j-l*(n-i)];
                dp[i][j] %= MOD;
            }
        }
    }

    /*
    rep(j,s+1){
        rep(i,n){
            cout << dp[i][j] << ' ';
        }
        cout << endl;
    }
    */

    

    ans += dp[0][s];
    ans %= MOD;
    cout << ans << endl;
    return 0;
}
 
 
0