結果

問題 No.269 見栄っ張りの募金活動
ユーザー hiro71687khiro71687k
提出日時 2023-03-01 05:05:35
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 928 bytes
コンパイル時間 4,796 ms
コンパイル使用メモリ 261,728 KB
実行使用メモリ 814,608 KB
最終ジャッジ日時 2023-10-14 10:11:10
合計ジャッジ時間 7,933 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,372 KB
testcase_01 AC 2 ms
4,368 KB
testcase_02 AC 1 ms
4,368 KB
testcase_03 AC 59 ms
13,856 KB
testcase_04 MLE -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll=long long;
using ld=long double;
ld pie=3.14159265359;
ll inf=80010010010010010;
ll mod=1000000007;
// 分割数
template<class T> struct Partition {
    vector<vector<T> > P;
    constexpr Partition(ll MAX) noexcept : P(MAX, vector<T>(MAX, 0)) {
        for (int k = 0; k < MAX; ++k) P[0][k] = 1;
        for (int n = 1; n < MAX; ++n) {
            for (int k = 1; k < MAX; ++k) {
                P[n][k] = (P[n][k-1] + (n-k >= 0 ? P[n-k][k] : 0))%mod;
                P[n][k]%=mod;
            }
        }
    }
    constexpr T get(ll n, ll 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+100);
    cout << pt.get(s,n) << endl;
}
0