結果

問題 No.269 見栄っ張りの募金活動
ユーザー reew2nreew2n
提出日時 2015-12-11 18:49:21
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 13 ms / 5,000 ms
コード長 494 bytes
コンパイル時間 425 ms
コンパイル使用メモリ 52,744 KB
実行使用メモリ 19,132 KB
最終ジャッジ日時 2023-09-23 01:15:49
合計ジャッジ時間 1,557 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
5,540 KB
testcase_03 AC 4 ms
12,104 KB
testcase_04 AC 7 ms
11,432 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 5 ms
15,772 KB
testcase_07 AC 13 ms
19,132 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 8 ms
17,148 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 3 ms
5,204 KB
testcase_12 AC 7 ms
16,400 KB
testcase_13 AC 4 ms
8,448 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 4 ms
6,544 KB
testcase_16 AC 6 ms
12,576 KB
testcase_17 AC 3 ms
10,060 KB
testcase_18 AC 9 ms
15,300 KB
testcase_19 AC 5 ms
8,364 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 3 ms
8,076 KB
testcase_23 AC 3 ms
5,628 KB
testcase_24 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,b) FOR(i,0,b)
using namespace std;
typedef long long LL;
LL DP[101][20001];
LL sum[22001];
const LL p=7+1e+9;
int main() {
	LL N,S,K;
	cin >> N >> S >> K;
	DP[0][0]=1;
	LL c=0;
	FOR(i,1,N+1){
		LL suv=(N-i+1);
		REP(j,S+1) sum[j]=DP[i-1][j];
		REP(j,S+1) sum[j+suv]+=sum[j];
		FOR(j,c*suv,S+1) DP[i][j]=sum[j-c*suv];
		REP(j,S+1) DP[i][j]%=p;
		c=K;
	}
	cout << DP[N][S] << endl;
	// your code goes here
	return 0;
}
0