結果

問題 No.41 貯金箱の溜息(EASY)
ユーザー ふーらくたるふーらくたる
提出日時 2016-08-05 19:30:09
言語 C++11
(gcc 8.5.0)
結果
AC  
実行時間 2,062 ms / 5,000 ms
コード長 774 bytes
コンパイル時間 454 ms
使用メモリ 3,900 KB
最終ジャッジ日時 2022-12-13 03:32:32
合計ジャッジ時間 3,156 ms
ジャッジサーバーID
(参考情報)
judge10 / judge14
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <numeric>
using namespace std;

typedef long long ll;

const ll MOD = 1000 * 1000 * 1000 + 9;
const ll MAX_M = 10000000000LL;

const auto PRICE1 = 111111;

int main() {
    int T;
    cin >> T;

    static vector<ll> dp(MAX_M / PRICE1 + 1, 0);
    dp[0] = 1;
    for (auto price = 1; price <= 9; price++) {
        for (auto use = 0; use < dp.size(); use++) {
            if (use - price < 0) continue;
            dp[use] += dp[use - price];
            dp[use] %= MOD;
        }
    }

    while (T--) {
        ll M;
        cin >> M;

        ll ans = 0;
        for (auto use = 0; use <= M / PRICE1; use++) {
            ans += dp[use];
            ans %= MOD;
        }
        cout << ans << endl;
    }
    return 0;
}
0