結果
| 問題 | No.41 貯金箱の溜息(EASY) | 
| コンテスト | |
| ユーザー |  hotpepsi | 
| 提出日時 | 2015-04-01 02:03:03 | 
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 35 ms / 5,000 ms | 
| コード長 | 701 bytes | 
| コンパイル時間 | 573 ms | 
| コンパイル使用メモリ | 65,632 KB | 
| 実行使用メモリ | 14,192 KB | 
| 最終ジャッジ日時 | 2024-07-03 23:05:10 | 
| 合計ジャッジ時間 | 1,122 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 2 | 
ソースコード
#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;
}
            
            
            
        