結果
問題 | No.269 見栄っ張りの募金活動 |
ユーザー |
|
提出日時 | 2021-08-24 18:24:27 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 17 ms / 5,000 ms |
コード長 | 768 bytes |
コンパイル時間 | 2,048 ms |
コンパイル使用メモリ | 197,324 KB |
最終ジャッジ日時 | 2025-01-24 01:46:14 |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 22 |
ソースコード
#include <bits/stdc++.h>using namespace std;#define rep(i, n) for (int i = 0; i < (n); ++i)using ll = long long;using P = pair<int, int>;int const INF = 1e9 + 7;int main() {int n, s, k;cin >> n >> s >> k;int m = s - (n - 1) * n * k / 2;if (m < 0) {cout << 0 << endl;return 0;}// DPテーブル// dp[i][j]...jのi分割の総数vector<vector<ll>> dp(n + 1, vector<ll>(m + 1));dp[0][0] = 1;for (int i = 1; i <= n; ++i) {for (int j = 0; j <= m; ++j) {if (j - i >= 0) {dp[i][j] = (dp[i - 1][j] + dp[i][j - i]) % INF;} else {dp[i][j] = dp[i - 1][j];}}}cout << dp[n][m] << endl;return 0;}