結果

問題 No.41 貯金箱の溜息(EASY)
ユーザー hotpepsihotpepsi
提出日時 2015-04-01 02:03:03
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 32 ms / 5,000 ms
コード長 701 bytes
コンパイル時間 432 ms
コンパイル使用メモリ 65,420 KB
実行使用メモリ 13,156 KB
最終ジャッジ日時 2023-09-17 00:40:53
合計ジャッジ時間 1,068 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 23 ms
11,224 KB
testcase_01 AC 32 ms
13,156 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <vector>
#include <sstream>
#include <cstring>

using namespace std;

typedef long long LL;
const LL MOD = 1e9 + 9;
LL tbl[10][100000];

LL ways(LL types, LL amount) {
	if (types <= 0) {
		return 1;
	}
	LL &r = tbl[types][amount];
	if (r >= 0) {
		return r;
	}
	LL a = ways(types - 1, amount);
	if (amount >= types) {
		a = (a + ways(types, amount - types)) % MOD;
	}
	return r = a;
}

int main(int argc, char *argv[]) {
	string s;
	getline(cin, s);
	LL N = atoi(s.c_str());
	memset(tbl, -1, sizeof(tbl));
	for (LL i = 0; i < N; ++i) {
		getline(cin, s);
		stringstream ss(s);
		LL m;
		ss >> m;
		cout << ways(9, m / 111111) << endl;
	}
	return 0;
}
0