結果

問題 No.269 見栄っ張りの募金活動
ユーザー 37kt_
提出日時 2015-10-17 18:29:59
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
TLE  
実行時間 -
コード長 547 bytes
コンパイル時間 2,139 ms
コンパイル使用メモリ 159,264 KB
実行使用メモリ 11,368 KB
最終ジャッジ日時 2024-07-22 10:25:16
合計ジャッジ時間 19,860 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21 TLE * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

const int MOD = 1e9 + 7;

int n, s, k;
int dp[101][20001];

int calc(int i, int s)
{
	if (s < 0) return 0;
	if (i == n) return !s;
	if (~dp[i][s]) return dp[i][s];
	int res = 0;
	for (int j = 0;; j++){
		int ns = s - (n - i) * j;
		if (ns < 0) break;
		res = (res + calc(i + 1, ns)) % MOD;
	}
	return dp[i][s] = res;
}

int main()
{
	cin >> n >> s >> k;
	
	int S = s - k * n * (n - 1) / 2;
	if (S < 0){
		cout << 0 << endl;
		return 0;
	}
	
	memset(dp, -1, sizeof(dp));
	cout << calc(0, S) << endl;
}
0