結果

問題 No.269 見栄っ張りの募金活動
ユーザー noisy_noimin
提出日時 2019-06-19 22:28:01
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 18 ms / 5,000 ms
コード長 917 bytes
コンパイル時間 515 ms
コンパイル使用メモリ 64,144 KB
実行使用メモリ 19,196 KB
最終ジャッジ日時 2024-11-30 08:07:07
合計ジャッジ時間 1,620 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

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