結果
問題 | No.269 見栄っ張りの募金活動 |
ユーザー |
|
提出日時 | 2019-09-06 20:53:36 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 70 ms / 5,000 ms |
コード長 | 1,142 bytes |
コンパイル時間 | 1,098 ms |
コンパイル使用メモリ | 97,184 KB |
実行使用メモリ | 20,224 KB |
最終ジャッジ日時 | 2024-06-24 12:37:09 |
合計ジャッジ時間 | 2,271 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 22 |
ソースコード
#include <cstdio>#include <iostream>#include <string>#include <sstream>#include <stack>#include <algorithm>#include <cmath>#include <queue>#include <map>#include <set>#include <cstdlib>#include <bitset>#include <tuple>#include <assert.h>#include <fstream>#include <bitset>template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }const long long INF = 1LL << 60;const long long MOD = 1000000007LL;const long long MAX = 500000LL;using namespace std;typedef unsigned long long ull;typedef long long ll;ll N, S, K;vector<vector<ll>> dp;ll dfs(ll n, ll k) {if (k == 1) return 1;if (dp[n][k] != -1) return dp[n][k];ll res = 0;res += dfs(n, k - 1);res %= MOD;if (n - k >= 0)res += dfs(n - k, k);res %= MOD;return dp[n][k] = res;}int main(){cin >> N >> S >> K;dp = vector<vector<ll>>(S + 1, vector<ll>(N + 1, -1));ll sum = 0;for (ll i = 0; i < N; i++) {S -= i * K;}if (S < 0) {cout << "0" << endl;return 0;}cout << dfs(S, N) << endl;return 0;}