結果

問題 No.269 見栄っ張りの募金活動
ユーザー hiro71687khiro71687k
提出日時 2023-03-01 05:30:16
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 30 ms / 5,000 ms
コード長 871 bytes
コンパイル時間 4,297 ms
コンパイル使用メモリ 260,240 KB
実行使用メモリ 11,792 KB
最終ジャッジ日時 2023-10-14 10:27:49
合計ジャッジ時間 5,659 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 1 ms
4,352 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 3 ms
4,352 KB
testcase_04 AC 28 ms
10,972 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 1 ms
4,348 KB
testcase_07 AC 30 ms
11,792 KB
testcase_08 AC 2 ms
4,352 KB
testcase_09 AC 2 ms
4,352 KB
testcase_10 AC 2 ms
4,352 KB
testcase_11 AC 24 ms
9,784 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 15 ms
6,976 KB
testcase_14 AC 30 ms
11,776 KB
testcase_15 AC 17 ms
8,012 KB
testcase_16 AC 1 ms
4,348 KB
testcase_17 AC 2 ms
4,352 KB
testcase_18 AC 15 ms
7,420 KB
testcase_19 AC 9 ms
5,788 KB
testcase_20 AC 11 ms
6,092 KB
testcase_21 AC 26 ms
10,300 KB
testcase_22 AC 9 ms
5,628 KB
testcase_23 AC 2 ms
4,352 KB
testcase_24 AC 18 ms
7,884 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll=int;
using ld=long double;
ld pie=3.14159265359;
ll inf=80010010;
ll mod=1000000007;
template<class T> struct Partition {
    vector<vector<T> > P;
    constexpr Partition(int MAX) noexcept : P(MAX, vector<T>(101, 0)) {
        for (int k = 0; k < 101; ++k) P[0][k] = 1;
        for (int n = 1; n < MAX; ++n) {
            for (int k = 1; k < 101; ++k) {
                P[n][k] = (P[n][k-1] + (n-k >= 0 ? P[n-k][k] : 0))%mod;
            }
        }
    }
    constexpr T get(int n, int k) {
        if (n < 0 || k < 0) return 0;
        return P[n][k];
    }
};
int main(){
    ll n,k,s;
    cin >> n >> s >> k;
    s-=((n*(n-1))/2)*k;
    if (s<0)
    {
        cout << 0 << endl;
        return 0;
    }
    Partition<ll>pt(s+1);
    cout << pt.get(s,n) << endl;
}
0