結果

問題 No.269 見栄っ張りの募金活動
ユーザー ZUBAZUBA
提出日時 2024-04-02 11:45:50
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 36 ms / 5,000 ms
コード長 1,771 bytes
コンパイル時間 5,526 ms
コンパイル使用メモリ 310,972 KB
実行使用メモリ 19,712 KB
最終ジャッジ日時 2024-04-02 11:45:57
合計ジャッジ時間 6,493 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 3 ms
6,676 KB
testcase_04 AC 14 ms
9,216 KB
testcase_05 AC 2 ms
6,676 KB
testcase_06 AC 2 ms
6,676 KB
testcase_07 AC 36 ms
19,712 KB
testcase_08 AC 2 ms
6,676 KB
testcase_09 AC 2 ms
6,676 KB
testcase_10 AC 2 ms
6,676 KB
testcase_11 AC 5 ms
6,676 KB
testcase_12 AC 2 ms
6,676 KB
testcase_13 AC 6 ms
6,676 KB
testcase_14 AC 3 ms
6,676 KB
testcase_15 AC 6 ms
6,676 KB
testcase_16 AC 2 ms
6,676 KB
testcase_17 AC 2 ms
6,676 KB
testcase_18 AC 13 ms
8,832 KB
testcase_19 AC 5 ms
6,676 KB
testcase_20 AC 3 ms
6,676 KB
testcase_21 AC 3 ms
6,676 KB
testcase_22 AC 4 ms
6,676 KB
testcase_23 AC 2 ms
6,676 KB
testcase_24 AC 3 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#include<atcoder/all>
using namespace atcoder;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vd = vector<double>;
using vs = vector<string>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vl = vector<long long>;
using vvl = vector<vl>;
#define inf 2147483642//int max
#define linf 900000000000000000
const double PI = 3.1415926535897932384626433832795028841971;
template<typename T>inline bool chmax(T& a, T b) { return ((a < b) ? (a = b, true) : (false)); }
template<typename T>inline bool chmin(T& a, T b) { return ((a > b) ? (a = b, true) : (false)); }
long long llceil(long long a, long long b) { if (a % b == 0) { return a / b; }return (a / b) + 1; }
#define yes cout<<"Yes"<<endl;
#define no cout<<"No"<<endl;
#define yesno(ans) cout<<(ans?"Yes":"No")<<endl;
#define sortu(a) sort(a.begin(),a.end());



long long split_num(long long k,long long n,long long M) {
	
	if (n < 0 || k < 0) {
		return 0;
	}

	vector<vector<long long>> split_dp(k + 1, vl(n + 1));
	split_dp[0][0] = 1;

	for (long long i = 1; i <= k; i++) {
		for (long long j = 0; j <= n; j++) {
			if (j-i >= 0) {
				split_dp[i][j] = (split_dp[i - 1][j] + split_dp[i][j - i]) % M;
			}
			else {
				split_dp[i][j] = (split_dp[i - 1][j]);
			}
		}
	}
	return split_dp[k][n];
}



int main() {
	//分割DP

	ll n, s, k; cin >> n >> s >> k;

	ll zub = s - n*(n - 1)/2 * k;//最低何円

	//これをn分割
	ll M = 1e9 + 7;
	if (zub <0) {
		cout << 0 << endl;
		return 0;
	}


	ll ans = split_num(n, zub, M);
	cout << ans << endl;
	



	return 0;
}
0