結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 5 ms
4,376 KB
testcase_04 AC 748 ms
6,256 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1,063 ms
11,204 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 315 ms
4,376 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 137 ms
4,380 KB
testcase_14 AC 93 ms
4,376 KB
testcase_15 AC 199 ms
4,380 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 210 ms
6,632 KB
testcase_19 AC 66 ms
4,376 KB
testcase_20 AC 44 ms
4,376 KB
testcase_21 AC 147 ms
4,376 KB
testcase_22 AC 49 ms
4,376 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 119 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[0][S] = 1;
		for(register int x = 0 ; x < N ; x++){
			register int tmp = N-x;
			for(register int s = 0 ; s <= S ; s++){
				if( dp[x][s] == 0 ) continue;
				register int c = 0;
				register int C = dp[x][s];
				for(int k = 0 ; c <= s ; k++){
					if( c > s ) break;
					dp[x+1][s-c] += C;
					if( dp[x+1][s-c] >= 1000000007 ) dp[x+1][s-c] -= 1000000007;
					c += tmp;
				}
			}
		}
		cout << dp[N][0] << endl;
	}
	
}
0