結果

問題 No.269 見栄っ張りの募金活動
ユーザー fumiphysfumiphys
提出日時 2018-07-04 20:06:41
言語 C++11
(gcc 13.3.0)
結果
AC  
実行時間 15 ms / 5,000 ms
コード長 543 bytes
コンパイル時間 596 ms
コンパイル使用メモリ 60,168 KB
実行使用メモリ 11,264 KB
最終ジャッジ日時 2024-07-16 02:05:51
合計ジャッジ時間 1,458 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cmath>

#define ll long long int

using namespace std;

const int mod = 1e9 + 7;

int dp[20001][101];

int main(int argc, char const* argv[])
{
	int n, s, k;
	cin >> n >> s >> k;
	s -= k * (n - 1) * n / 2;
	if(s < 0){
			cout << 0 << endl;
			return 0;
	}
	for(int i = 0; i <= n; i++)dp[0][i] = 1;
	for(int i = 1; i <= s; i++){
			for(int j = 1; j <= n; j++){
					if(i >= j)dp[i][j] = int(((ll)dp[i-j][j] + (ll)dp[i][j-1]) % mod);
					else dp[i][j] = dp[i][j-1];
			}
	}
	cout << dp[s][n] << endl;
	return 0;
}
0