結果

問題 No.269 見栄っ張りの募金活動
ユーザー noisy_noiminnoisy_noimin
提出日時 2019-06-19 22:28:01
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 20 ms / 5,000 ms
コード長 917 bytes
コンパイル時間 954 ms
コンパイル使用メモリ 64,092 KB
実行使用メモリ 19,156 KB
最終ジャッジ日時 2023-08-20 07:19:46
合計ジャッジ時間 1,943 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 20 ms
18,224 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 16 ms
19,156 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 15 ms
15,532 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 10 ms
10,256 KB
testcase_14 AC 19 ms
19,080 KB
testcase_15 AC 11 ms
12,056 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 9 ms
11,736 KB
testcase_19 AC 7 ms
8,024 KB
testcase_20 AC 8 ms
8,572 KB
testcase_21 AC 16 ms
16,488 KB
testcase_22 AC 7 ms
7,452 KB
testcase_23 AC 3 ms
4,380 KB
testcase_24 AC 11 ms
11,976 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>

#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()

using namespace std;

using ll =  long long;

constexpr ll MOD = 1000000007;
constexpr int N_MAX = 20000;
constexpr int M_MAX = 100;

namespace Partition {
    int n, m; // ボールの個数,グループ数
    ll p[N_MAX+1][M_MAX+1];
    
    void init(int nn, int mm) {
        n = nn;
        m = mm;
        p[0][0] = 1;
        for(int j=1;j<=m;++j) p[0][j] = 1;
        for(int i=1;i<=n;++i) {
            for(int j=1;j<=m;++j) {
                p[i][j] = (p[i][j-1] + (i-j<0?0:p[i-j][j])) % MOD;
            }
        }
    }

    const ll get(int i, int j) {
        return p[i][j];
    }
}

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

    if(ss < 0) {
        cout << 0 << endl;
        return 0;
    }

    Partition::init(ss, n);

    cout << Partition::get(ss, n) << endl;
}
0