結果
問題 | No.269 見栄っ張りの募金活動 |
ユーザー |
|
提出日時 | 2021-09-12 13:32:55 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 25 ms / 5,000 ms |
コード長 | 1,354 bytes |
コンパイル時間 | 862 ms |
コンパイル使用メモリ | 80,288 KB |
最終ジャッジ日時 | 2025-01-24 13:11:19 |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 22 |
ソースコード
#include <iostream> #include <vector> #include <algorithm> #include <tuple> #include <queue> using namespace std; using ll = long long; using pii = pair<int, int>; using pll = pair<ll, ll>; using pil = pair<int, ll>; using pli = pair<ll, int>; using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>; using vll = vector<ll>; using vvll = vector<vll>; using vvvll = vector<vvll>; using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>; template <class T> using pqr = priority_queue<T, vector<T>, greater<T>>; const ll INFL = (ll)1e18; const int INF = (int)1e9; const int MOD = 1000000007; template <class T> inline bool chmax(T& M, const T& x) { if (M < x) { M = x; return true; } return false; } // 最大値を更新(更新されたら true を返す) template <class T> inline bool chmin(T& m, const T& x) { if (m > x) { m = x; return true; } return false; } // 最小値を更新(更新されたら true を返す) int main() { int N, S, K; cin >> N >> S >> K; vvi DP(S + 1, vi(N + 1, 0)); for (int i = 0; i <= S; i++) DP[i][1] = 1; for (int i = 0; i <= S; i++) { for (int j = 2; j <= N; j++) { if (i - j >= 0) DP[i][j] += DP[i - j][j]; if (i - K * (j - 1) >= 0) DP[i][j] += DP[i - K * (j - 1)][j - 1]; DP[i][j] %= MOD; } } cout << DP[S][N] << endl; return 0; }