結果
問題 | No.41 貯金箱の溜息(EASY) |
ユーザー |
![]() |
提出日時 | 2015-04-01 02:03:03 |
言語 | C++11 (gcc 8.5.0) |
結果 |
AC
|
実行時間 | 39 ms / 5,000 ms |
コード長 | 701 bytes |
コンパイル時間 | 425 ms |
使用メモリ | 13,108 KB |
最終ジャッジ日時 | 2023-02-05 06:13:10 |
合計ジャッジ時間 | 1,215 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge11 |
テストケース
テストケース表示入力 | 結果 | 実行時間 使用メモリ |
---|---|---|
testcase_00 | AC | 26 ms
11,124 KB |
testcase_01 | AC | 39 ms
13,108 KB |
ソースコード
#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; }