結果

問題 No.269 見栄っ張りの募金活動
ユーザー sugim48sugim48
提出日時 2015-08-21 22:53:11
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 4,532 ms / 5,000 ms
コード長 1,132 bytes
コンパイル時間 737 ms
コンパイル使用メモリ 79,116 KB
実行使用メモリ 10,920 KB
最終ジャッジ日時 2023-09-23 01:04:15
合計ジャッジ時間 16,607 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 18 ms
4,380 KB
testcase_04 AC 3,213 ms
6,156 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 4,532 ms
10,920 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 21 ms
6,436 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 1,560 ms
4,376 KB
testcase_12 AC 8 ms
5,748 KB
testcase_13 AC 653 ms
4,376 KB
testcase_14 AC 490 ms
4,380 KB
testcase_15 AC 931 ms
4,380 KB
testcase_16 AC 25 ms
5,804 KB
testcase_17 AC 3 ms
4,376 KB
testcase_18 AC 1,132 ms
8,000 KB
testcase_19 AC 348 ms
4,384 KB
testcase_20 AC 216 ms
4,376 KB
testcase_21 AC 773 ms
4,380 KB
testcase_22 AC 226 ms
4,376 KB
testcase_23 AC 8 ms
4,376 KB
testcase_24 AC 579 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };
 
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;
int INF = INT_MAX / 10;

int K, unko;

int f(int N, int S, vector<vector<int> >& memo) {
	if (memo[N][S] != -1) return memo[N][S];
	if (N == 0) return S == 0;
	int sum = 0;
	for (int y = (N == unko ? 0 : K); N * y <= S; y++) {
		sum += f(N - 1, S - N * y, memo);
		if (sum >= MOD) sum -= MOD;
	}
	return memo[N][S] = sum;
}

int main() {
	int N, S; cin >> N >> S >> K;
	unko = N;
	vector<vector<int> > memo(N + 1, vector<int>(S + 1, -1));
	cout << f(N, S, memo) << endl;
}
0