結果

問題 No.269 見栄っ張りの募金活動
ユーザー f1b_maxbl00df1b_maxbl00d
提出日時 2019-05-08 19:18:03
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 12 ms / 5,000 ms
コード長 1,065 bytes
コンパイル時間 719 ms
コンパイル使用メモリ 81,596 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-14 17:23:32
合計ジャッジ時間 1,985 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

void solve();

int main() {
	solve();
	return 0;
}

//////////////////////////////////////////////////
//////////////////////////////////////////////////
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#include <functional>
#include <map>


using namespace std;

typedef pair<int, int> pii;

//分割数求める
//和S以下、n分割、M剰余
//保存用空vector<int>指定
//もうめんどくさいから全部long intで(適当)
void divisionNumber(long int S, long int n, long int M,vector<long int>& v) {
	v.resize(S+1);
	for (int n = 0; n <= S; n++)v[n] = 0;
	v[0] = 1;
	for (int i = 1; i <= n; i++) {   //i分割
		for (int j = 0; j <= S; j++) {   //和j
			if (j - i >= 0)v[j] += v[j - i];
			if (v[j] >= M)v[j] -= M;
		}
	}
	return;
}

long int N, S, K;
long int M;

void solve() {
	cin >> N >> S >> K;
	M = 1000000000 + 7;
	vector<long int> v;
	if (S - (N - 1)*N*K / 2 < 0) {
		cout << 0 << endl;
		return;
	}
	divisionNumber(S - (N - 1)*N*K / 2, N, M, v);
	cout << v[S - (N - 1)*N*K / 2] << endl;
	return;
}
0