結果

問題 No.269 見栄っ張りの募金活動
ユーザー 👑 jupirojupiro
提出日時 2019-09-06 20:53:36
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 59 ms / 5,000 ms
コード長 1,142 bytes
コンパイル時間 865 ms
コンパイル使用メモリ 94,648 KB
実行使用メモリ 20,244 KB
最終ジャッジ日時 2023-09-06 18:13:00
合計ジャッジ時間 2,017 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 3 ms
4,672 KB
testcase_04 AC 19 ms
10,536 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 59 ms
20,244 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 6 ms
10,656 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 5 ms
6,020 KB
testcase_12 AC 5 ms
8,776 KB
testcase_13 AC 6 ms
5,676 KB
testcase_14 AC 3 ms
5,004 KB
testcase_15 AC 6 ms
5,776 KB
testcase_16 AC 4 ms
8,472 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 20 ms
13,580 KB
testcase_19 AC 5 ms
6,112 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 3 ms
4,644 KB
testcase_22 AC 3 ms
4,660 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 3 ms
4,432 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <fstream>
#include <bitset>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long INF = 1LL << 60;
const long long MOD = 1000000007LL;
const long long MAX = 500000LL;
using namespace std;
typedef unsigned long long ull;
typedef  long long ll;

ll N, S, K;
vector<vector<ll>> dp;
ll dfs(ll n, ll k) {
	if (k == 1) return 1;
	if (dp[n][k] != -1) return dp[n][k];
	ll res = 0;
	res += dfs(n, k - 1);
	res %= MOD;
	if (n - k >= 0)
		res += dfs(n - k, k);
	res %= MOD;
	return dp[n][k] = res;
}
int main()
{
	cin >> N >> S >> K;
	dp = vector<vector<ll>>(S + 1, vector<ll>(N + 1, -1));
	ll sum = 0;
	for (ll i = 0; i < N; i++) {
		S -= i * K;
	}
	if (S < 0) {
		cout << "0" << endl;
		return 0;
	}
	cout << dfs(S, N) << endl;
	return 0;
}
0