結果

問題 No.269 見栄っ張りの募金活動
ユーザー Tatsuro MiyazakiTatsuro Miyazaki
提出日時 2018-12-18 18:24:03
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 18 ms / 5,000 ms
コード長 1,240 bytes
コンパイル時間 626 ms
コンパイル使用メモリ 73,316 KB
実行使用メモリ 19,264 KB
最終ジャッジ日時 2023-10-25 23:41:13
合計ジャッジ時間 2,004 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

#define MAX_V 1000000

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, S, K;
	cin >> N >> S >> K;

	int n = S - K * (N - 1) * N / 2;
	if(n < 0) {
		cout << 0 << endl;
		return 0;
	}
	int m = N;
	ll dp[m + 1][n + 1];
	memset(dp, 0, sizeof(dp));
	dp[0][0] = 1;

	ll mod = 1e9 + 7;
	rep(i, 1, m + 1) rep(j, 0, n + 1) {
		if(j - i >= 0) dp[i][j] = (dp[i - 1][j] + dp[i][j - i]) % mod;
		else dp[i][j] = dp[i - 1][j];
	}

	cout << dp[m][n] << endl;
}
0