結果

問題 No.269 見栄っ張りの募金活動
ユーザー reew2n
提出日時 2015-12-11 18:49:21
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 14 ms / 5,000 ms
コード長 494 bytes
コンパイル時間 732 ms
コンパイル使用メモリ 55,284 KB
実行使用メモリ 19,120 KB
最終ジャッジ日時 2024-07-16 01:52:20
合計ジャッジ時間 1,528 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

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