結果

問題 No.269 見栄っ張りの募金活動
ユーザー koyumeishikoyumeishi
提出日時 2015-08-21 23:07:56
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 1,438 ms / 5,000 ms
コード長 827 bytes
コンパイル時間 648 ms
コンパイル使用メモリ 75,352 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-25 15:22:38
合計ジャッジ時間 8,720 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 3 ms
4,376 KB
testcase_03 AC 23 ms
4,376 KB
testcase_04 AC 1,166 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1,438 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 279 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 746 ms
4,376 KB
testcase_12 AC 206 ms
4,376 KB
testcase_13 AC 234 ms
4,376 KB
testcase_14 AC 266 ms
4,376 KB
testcase_15 AC 336 ms
4,380 KB
testcase_16 AC 318 ms
4,380 KB
testcase_17 AC 21 ms
4,376 KB
testcase_18 AC 984 ms
4,380 KB
testcase_19 AC 237 ms
4,380 KB
testcase_20 AC 86 ms
4,380 KB
testcase_21 AC 280 ms
4,376 KB
testcase_22 AC 79 ms
4,380 KB
testcase_23 AC 6 ms
4,376 KB
testcase_24 AC 187 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <cstdio>
#include <sstream>
#include <map>
#include <string>
#include <algorithm>
#include <queue>
#include <cmath>
#include <set>
using namespace std;
#define MOD 1000000007

ostream& operator << (ostream& os, vector<long long>& v){
	for(int i=0; i<v.size(); i++){
		os << v[i] << " ";
	}
	return os;
}

int main(){
	long long n,s,k;
	cin >> n >> s >> k;

	vector<long long> dp(s+1, 0);
	for(int i=0; i<=s; i++){
		if(s < i*n) break;
		dp[s - i*n] = 1;
	}
	
	//cerr << dp << endl;

	for(int i=1; i<n; i++){
		vector<long long> dp_(s+1, 0);
		for(int j=0; j<=s; j++){
			for(int a=k; a<=s; a++){
				if(j-a*(n-i) < 0) break;
				long long& nx = dp_[ j-a*(n-i) ];
				nx = nx + dp[j];
				if(nx >= MOD) nx -= MOD;
			}
		}
		swap(dp, dp_);
	}

	cout << dp[0] << endl;

	return 0;
}
0