結果
問題 | No.269 見栄っ張りの募金活動 |
ユーザー |
![]() |
提出日時 | 2015-08-24 14:11:38 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 4 ms / 5,000 ms |
コード長 | 522 bytes |
コンパイル時間 | 1,335 ms |
コンパイル使用メモリ | 158,620 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-16 01:34:58 |
合計ジャッジ時間 | 2,218 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 22 |
ソースコード
#include <bits/stdc++.h> using namespace std; int n, s, k; void input() { cin >> n >> s >> k; } const int S = 20010; const int mod = 1000000007; int dp[S]; int solve() { s -= n * (n - 1) / 2 * k; if (s < 0) return 0; dp[0] = 1; for (int i = 0; i < n; ++i) { const int t = n - i; for (int j = t; j <= s; ++j) { dp[j] += dp[j - t]; if (dp[j] >= mod) dp[j] -= mod; } } return dp[s]; } int main() { input(); cout << solve() << endl; }