結果

問題 No.269 見栄っ張りの募金活動
ユーザー kyuridenamidakyuridenamida
提出日時 2015-08-21 23:29:46
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 1,075 ms / 5,000 ms
コード長 781 bytes
コンパイル時間 1,133 ms
コンパイル使用メモリ 145,308 KB
実行使用メモリ 11,528 KB
最終ジャッジ日時 2023-09-23 01:05:53
合計ジャッジ時間 5,718 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 5 ms
6,100 KB
testcase_04 AC 757 ms
7,452 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
5,692 KB
testcase_07 AC 1,075 ms
11,528 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 343 ms
4,376 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 141 ms
6,448 KB
testcase_14 AC 271 ms
4,380 KB
testcase_15 AC 207 ms
4,376 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 212 ms
7,520 KB
testcase_19 AC 69 ms
6,224 KB
testcase_20 AC 51 ms
4,380 KB
testcase_21 AC 232 ms
4,380 KB
testcase_22 AC 50 ms
4,380 KB
testcase_23 AC 3 ms
4,380 KB
testcase_24 AC 139 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int sum[20210] = {};
int dp[110][20110];
int N,S,K;
vector<int> v;
int dfs(int x,int s){
	if( s < 0 ) return 0;
	if( dp[x][s] != -1 ) return dp[x][s];
	if( x == 0 ){
		return s == 0;
	}
	int ans = 0;
	for(int i = 0 ; ; i++){
		int c = i * x;
		if( c > s ) break;
		ans += dfs(x-1,s-c); 
		ans %= 1000000007;
	}
	return dp[x][s] = ans;
}



int main(){
	cin >> N >> S >> K;
	S -= K*N*(N-1)/2;
	if( S < 0 ) cout << 0 << endl;
	else{	
		dp[N][S] = 1;
		for(int x = N ; x >= 1 ; x--){
			for(int s = 0 ; s <= S ; s++){
				for(int k = 0 ; ; k++){
					int c = k * x;
					if( c > s ) break;
					dp[x-1][s-c] += dp[x][s];
					if( dp[x-1][s-c] >= 1000000007 ) dp[x-1][s-c] -= 1000000007;
				}
			}
		}
		cout << dp[0][0] << endl;
	}
	
}
0