結果
問題 | No.269 見栄っ張りの募金活動 |
ユーザー |
|
提出日時 | 2022-01-22 01:20:04 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 1,538 ms / 5,000 ms |
コード長 | 1,053 bytes |
コンパイル時間 | 1,960 ms |
コンパイル使用メモリ | 199,120 KB |
最終ジャッジ日時 | 2025-01-27 14:43:13 |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 22 |
ソースコード
#include <bits/stdc++.h>using namespace std;using ll = long long;constexpr ll mod = 1e9 + 7;constexpr ll INF = 1LL << 60;#define REP(i, init, n) for(int i = (int)(init); i < (int)(n); i++)#define vi vector<int>#define vl vector<long>#define vvi vector<vector<int>>#define vvl vector<vector<long>>#define pint pair<int, int>#define plong pair<long, long>int N, S, K;void solve() {S -= K * (N - 1) * N / 2;if(S < 0) {cout << 0 << endl;return;}vvl dp(N + 1, vl(S + 1, 0));dp[0][0] = 1;REP(i, 1, N + 1) {int add = N + 1 - i;REP(j, 0, S + 1) {if(i == N) {dp[i][S] += dp[i - 1][j];dp[i][S] %= mod;continue;}int m = 0;while(j + add * m <= S) {dp[i][j + add * m] += dp[i - 1][j];dp[i][j + add * m] %= mod;m++;}}}cout << dp[N][S] << endl;}int main() {cin >> N >> S >> K;solve();}