結果

問題 No.269 見栄っ張りの募金活動
ユーザー hiro71687k
提出日時 2023-03-01 05:05:35
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
MLE  
実行時間 -
コード長 928 bytes
コンパイル時間 3,749 ms
コンパイル使用メモリ 252,372 KB
最終ジャッジ日時 2025-02-11 00:27:54
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 13 TLE * 1 MLE * 8
権限があれば一括ダウンロードができます

ソースコード

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