結果
問題 | No.269 見栄っ張りの募金活動 |
ユーザー |
|
提出日時 | 2020-08-17 18:39:14 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 15 ms / 5,000 ms |
コード長 | 1,071 bytes |
コンパイル時間 | 3,013 ms |
コンパイル使用メモリ | 267,548 KB |
実行使用メモリ | 12,160 KB |
最終ジャッジ日時 | 2024-10-11 11:12:26 |
合計ジャッジ時間 | 3,657 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 22 |
ソースコード
//#define _GLIBCXX_DEBUG#include <bits/stdc++.h>#include <x86intrin.h>using namespace std;using ll = long long;using P = pair<int, int>;#define rep(i, n) for (int i = 0; i < (n); i++)#define all(v) v.begin(), v.end()#define allr(v) v.rbegin(), v.rend()#define V vectortemplate <typename T> bool chmin(T &a, const T &b) {if(a > b){a = b; return true;} return false;}template <typename T> bool chmax(T &a, const T &b) {if(a < b){a = b; return true;} return false;}V<int> dx = {-1, 1, 0, 0, -1, -1, 1, 1};V<int> dy = { 0, 0, -1, 1, -1, 1, -1, 1};const int mod = 1e9 + 7;int dp[20010][110];int main () {int n, s, k; cin >> n >> s >> k;memset(dp, 0, sizeof(dp));s -= (n-1) * n / 2 * k;if (s < 0) {cout << 0 << endl;return 0;}dp[0][0] = 1;for (int i = 0; i <= s; i++) {for (int j = 1; j <= n; j++) {if (i - j >= 0) dp[i][j] = dp[i][j-1] + dp[i-j][j];else dp[i][j] = dp[i][j-1];dp[i][j] %= mod;}}cout << dp[s][n] << endl;return 0;}