結果

問題 No.269 見栄っ張りの募金活動
コンテスト
ユーザー kyuridenamida
提出日時 2015-08-22 01:05:28
言語 C++11
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 4 ms / 5,000 ms
コード長 650 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,081 ms
コンパイル使用メモリ 176,016 KB
実行使用メモリ 6,144 KB
最終ジャッジ日時 2026-03-30 16:51:04
合計ジャッジ時間 2,888 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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



int main(){
	int N,S,K;
	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 = S ; s >= 0 ; s--){
				dp[cur^1][s] += dp[cur][s];
				if( dp[cur^1][s] >= 1000000007 ) dp[cur^1][s] -= 1000000007;
				if( s - x >= 0 ){
					dp[cur][s-x] += dp[cur][s];
					if( dp[cur][s-x] >= 1000000007 ) dp[cur][s-x] -= 1000000007;
				}
			}
			cur ^= 1;
		}
		cout << dp[cur][0] << endl;
	}
	
}
0