結果
問題 | No.269 見栄っ張りの募金活動 |
ユーザー |
![]() |
提出日時 | 2015-10-17 18:50:29 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 5 ms / 5,000 ms |
コード長 | 400 bytes |
コンパイル時間 | 1,423 ms |
コンパイル使用メモリ | 159,936 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-16 01:50:10 |
合計ジャッジ時間 | 2,367 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 22 |
ソースコード
#include <bits/stdc++.h> using namespace std; const int MOD = 1e9 + 7; int n, s, k; int dp[20001]; int main() { cin >> n >> s >> k; int S = s - k * n * (n - 1) / 2; if (S < 0){ cout << 0 << endl; return 0; } dp[0] = 1; for (int i = 0; i < n; i++){ int ds = n - i; for (int s = 0; s + ds <= S; s++){ dp[s + ds] += dp[s]; dp[s + ds] %= MOD; } } cout << dp[S] << endl; }