結果

問題 No.41 貯金箱の溜息(EASY)
ユーザー kimiyukikimiyuki
提出日時 2016-02-27 08:11:19
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 24 ms / 5,000 ms
コード長 835 bytes
コンパイル時間 788 ms
コンパイル使用メモリ 60,272 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-24 18:23:45
合計ジャッジ時間 1,237 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 23 ms
4,348 KB
testcase_01 AC 24 ms
4,348 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