結果

問題 No.269 見栄っ張りの募金活動
ユーザー sumi_blog
提出日時 2022-06-12 22:49:34
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 18 ms / 5,000 ms
コード長 678 bytes
コンパイル時間 882 ms
コンパイル使用メモリ 86,940 KB
実行使用メモリ 11,776 KB
最終ジャッジ日時 2024-09-24 09:19:10
合計ジャッジ時間 1,760 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<stack>
#include<string>

#define rep(i,n) for(int i=0;i<(n);i++)

using ll = long long;
using namespace std;

const int MOD = 1000000007;

int main() {
	int n, s, k;
	cin >> n >> s >> k;

	int S = s - n * (n - 1) * k / 2;
	if (S < 0) {
		cout << 0 << endl;
		return 0;
	}

	vector<vector<int>> dp(S + 1, vector<int>(n + 1, 0));
	rep(i, n + 1) dp[0][i] = 1;

	for (int i = 1; i <= S; i++) {
		for (int k = 1; k <= n; k++) {
			dp[i][k] = dp[i][k - 1] + (i - k >= 0 ? dp[i - k][k] : 0);
			dp[i][k] %= MOD;
		}
	}

	cout << dp[S][n] << endl;

	return 0;
}
0