結果
問題 |
No.269 見栄っ張りの募金活動
|
ユーザー |
|
提出日時 | 2020-04-16 10:01:00 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 10 ms / 5,000 ms |
コード長 | 1,366 bytes |
コンパイル時間 | 782 ms |
コンパイル使用メモリ | 92,652 KB |
実行使用メモリ | 19,100 KB |
最終ジャッジ日時 | 2024-11-14 22:18:15 |
合計ジャッジ時間 | 1,671 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 22 |
ソースコード
#include <iostream> #include <iomanip> #include <vector> #include <stack> #include <queue> #include <set> #include <map> #include <algorithm> #include <cstdio> #include <utility> #include <string> #include <cmath> #include <cstdlib> #include <cstring> #include <deque> #include <numeric> using namespace std; typedef uint64_t u64; typedef int64_t s64; typedef uint32_t u32; typedef int32_t s32; typedef vector<s32> vs32; typedef vector<u32> vu32; typedef vector<s64> vs64; typedef vector<u64> vu64; const double PI=3.14159265358979323846; #define MAX(x, y) ((x) < (y) ? (y) : (x)) #define MIN(x, y) ((x) > (y) ? (y) : (x)) #define rep(i, N) for(int i = 0; i < N; ++i) #define CEIL(x, y) (((x) + (y) - 1) / (y)) #define MOD 1000000007ULL #define IN(l, r, x) ((l) <= (x) && (x) < (r)) int main() { cin.tie(0); ios::sync_with_stdio(false); int n, s, k; cin >> n >> s >> k; if (s < n * (n - 1) * k / 2) { cout << "0\n"; return 0; } int m = s - n * (n - 1) * k / 2; s64 dp[n + 1][m + 1]; rep (i, n + 1) rep (j, m + 1) dp[i][j] = 0; dp[0][0] = 1; for (int i = 1; i <= n; ++i) { rep (j, m + 1) { if (j - i >= 0) dp[i][j] = (dp[i][j - i] + dp[i - 1][j]) % MOD; else dp[i][j] = dp[i - 1][j]; } } cout << dp[n][m] << "\n"; return 0; }