結果
問題 |
No.269 見栄っ張りの募金活動
|
ユーザー |
![]() |
提出日時 | 2025-10-05 15:51:50 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 4 ms / 5,000 ms |
コード長 | 403 bytes |
コンパイル時間 | 1,199 ms |
コンパイル使用メモリ | 161,440 KB |
実行使用メモリ | 7,716 KB |
最終ジャッジ日時 | 2025-10-05 15:51:55 |
合計ジャッジ時間 | 2,099 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 22 |
ソースコード
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7, N = 1e6 + 5; int n, s, k, dp[N]; int main() { cin >> n >> s >> k; long long tmp = 1LL * k * n * (n - 1) / 2; if (tmp > s) { cout << 0 << "\n"; return 0; } int m = s - tmp; dp[0] = 1; for(int i = 1; i <= n; i ++ ) for(int j = i; j <= m; j ++ ) dp[j] = (dp[j - i] + dp[j]) % mod; cout << dp[m] << "\n"; return 0; }