結果
問題 | No.269 見栄っ張りの募金活動 |
ユーザー |
|
提出日時 | 2024-09-13 15:04:02 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 51 ms / 5,000 ms |
コード長 | 667 bytes |
コンパイル時間 | 2,889 ms |
コンパイル使用メモリ | 243,588 KB |
実行使用メモリ | 35,864 KB |
最終ジャッジ日時 | 2024-09-13 15:04:07 |
合計ジャッジ時間 | 4,264 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 22 |
ソースコード
#include <bits/stdc++.h>using namespace std;#define endl "\n"typedef long long ll;const int mod = 1e9 + 7;ll a[101][20010], l[101][20010];int n, s, k;int f(int n, int s) {if (l[n][s]++) return a[n][s];if (n == 0) return !s;return a[n][s] = (f(n - 1, s) + (s < n ? 0 : f(n, s - n))) % mod;}void solved() {memset(l, 0, sizeof l);memset(a, 0, sizeof a);cin >> n >> s >> k;if (n * (n - 1) / 2 * k > s) {cout << 0 << endl;return;}s -= n * (n - 1) / 2 * k;cout << f(n, s) << endl;}int main() {ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);/*int t = 1;cin >> t;while (t--)*/solved();return 0;}