結果

問題 No.41 貯金箱の溜息(EASY)
ユーザー kimiyukikimiyuki
提出日時 2016-02-27 08:11:19
言語 C++11
(gcc 8.5.0)
結果
AC  
実行時間 22 ms / 5,000 ms
コード長 835 bytes
コンパイル時間 377 ms
使用メモリ 3,544 KB
最終ジャッジ日時 2022-11-23 05:53:30
合計ジャッジ時間 1,557 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 21 ms
3,532 KB
testcase_01 AC 22 ms
3,544 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <cassert>
#define repeat(i,n) for (int i = 0; (i) < (n); ++(i))
typedef long long ll;
using namespace std;
const int coins[] = { 1, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
const ll unit = 111111;
const ll limit = 1e10;
const ll len = (limit + unit - 1) / unit + 1;
const ll mod = 1e9+9;
int main() {
    // prepare
    vector<int> dp(len);
    dp[0] = 1;
    for (int k : coins) {
        repeat (init,k) {
            ll acc = 0;
            for (ll i = init; i < len; i += k) {
                ll t = dp[i];
                dp[i] = (dp[i] + acc) % mod;
                acc = (acc + t) % mod;
            }
        }
    }
    // input / output
    int t; cin >> t;
    repeat (i,t) {
        ll m; cin >> m;
        assert (m <= limit);
        cout << dp[m / unit] << endl;
    }
    return 0;
}
0