結果

問題 No.269 見栄っ張りの募金活動
ユーザー a0171610a0171610
提出日時 2020-03-20 16:28:50
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 60 ms / 5,000 ms
コード長 429 bytes
コンパイル時間 1,580 ms
コンパイル使用メモリ 164,668 KB
実行使用メモリ 18,940 KB
最終ジャッジ日時 2023-08-21 01:19:40
合計ジャッジ時間 2,779 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int N, S, K;
long mod=1e9+7,dp[101][20001];

int main(){
	cin >> N >> S >> K;
	for(int i = 0; i < N; i++) S -= i*K;
	if(S < 0){
		cout << 0 << endl;
		return 0;
	}
	dp[0][0]=1;
	for(int i = 0;i <= N; i++){
    for(int j = 0;j <= S; j++){
		  if(i < N) (dp[i + 1][j] += dp[i][j])%=mod;
		  if(i > 0 && i + j <= S) (dp[i][i + j] += dp[i][j])%=mod;
    }
	}
	cout << dp[N][S] << endl;
}
0