結果

問題 No.269 見栄っ張りの募金活動
ユーザー kyuridenamidakyuridenamida
提出日時 2015-08-21 23:54:58
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 1,570 ms / 5,000 ms
コード長 639 bytes
コンパイル時間 1,091 ms
コンパイル使用メモリ 145,508 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-23 01:07:34
合計ジャッジ時間 7,080 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

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

int N,S,K;
vector<int> v;


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