結果

問題 No.269 見栄っ張りの募金活動
ユーザー 37kt_37kt_
提出日時 2015-10-17 18:29:59
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 547 bytes
コンパイル時間 1,706 ms
コンパイル使用メモリ 143,892 KB
実行使用メモリ 11,432 KB
最終ジャッジ日時 2023-09-29 16:19:36
合計ジャッジ時間 20,782 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 5 ms
11,216 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 20 ms
11,324 KB
testcase_04 AC 3,916 ms
11,160 KB
testcase_05 AC 6 ms
11,216 KB
testcase_06 AC 6 ms
11,276 KB
testcase_07 TLE -
testcase_08 AC 6 ms
11,140 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 6 ms
11,268 KB
testcase_11 AC 1,780 ms
11,160 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 799 ms
11,132 KB
testcase_14 AC 548 ms
11,132 KB
testcase_15 AC 1,129 ms
11,260 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 1,190 ms
11,196 KB
testcase_19 AC 382 ms
11,196 KB
testcase_20 AC 257 ms
11,200 KB
testcase_21 AC 880 ms
11,252 KB
testcase_22 AC 280 ms
11,336 KB
testcase_23 AC 11 ms
11,160 KB
testcase_24 AC 698 ms
11,380 KB
権限があれば一括ダウンロードができます

ソースコード

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