結果

問題 No.269 見栄っ張りの募金活動
コンテスト
ユーザー 小畑裕貴
提出日時 2026-03-02 13:07:10
言語 C++17
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 19 ms / 5,000 ms
コード長 2,162 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 4,321 ms
コンパイル使用メモリ 134,296 KB
実行使用メモリ 19,712 KB
最終ジャッジ日時 2026-03-02 13:07:20
合計ジャッジ時間 1,377 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <algorithm>
#include <array>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (int)(s); i < (int)(n); i++)
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vll = vector<long long>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using vvd = vector<vd>;
using vs = vector<string>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vc = vector<char>;
using vvc = vector<vc>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pil = pair<int, long long>;
using pli = pair<long long, int>;
using vpii = vector<pii>;
using vpll = vector<pll>;
using vpil = vector<pil>;
using vpli = vector<pli>;

const double PI = acos(-1);
const ll MOD = 1000000007;
const ll MODL = 2147483647;
const int INF = 1000000007;
const ll INFL = 1LL<<60;

template <typename T> inline bool chmin(T &a, T b) {if (a > b) {a = b; return true;} return false;}
template <typename T> inline bool chmax(T &a, T b) {if (a < b) {a = b; return true;} return false;}
// template <typename T> T gcd(T a, T b) {if (a < b) swap(a, b); if (b == 0) return a; else return gcd(b, a%b);}
template <typename T> inline T ceil(T a, T b) {return (a+(b-1))/b;}
template <typename T> inline T floor(T a, T b) {return a/b;}
inline void add(ll &a, ll b) {a = ((a % MOD + b % MOD)) % MOD;}
inline void sub(ll &a, ll b) {a = ((a % MOD - b % MOD) + MOD) % MOD;}
inline void mul(ll &a, ll b) {a = ((a % MOD) * (b % MOD)) % MOD;}


int main() {
    int n, s, K;
    cin >> n >> s >> K;
    rep(i, n) s -= i*K;
    if (s < 0) cout << 0 << endl;
    else {
        vvll dp(s+1, vll(n+1, 0));
        dp[0][0] = 1;
        rep(i, s+1) {
            rep2(j, 1, n+1) {
                if (i - j >= 0) dp[i][j] = (dp[i-j][j] + dp[i][j-1]) % MOD;
                else dp[i][j] = dp[i][j-1];
            }
        }
        cout << dp[s][n] << endl;
    }
}
0