結果
| 問題 | No.41 貯金箱の溜息(EASY) | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2016-02-27 08:11:19 | 
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 25 ms / 5,000 ms | 
| コード長 | 835 bytes | 
| コンパイル時間 | 573 ms | 
| コンパイル使用メモリ | 60,208 KB | 
| 実行使用メモリ | 6,944 KB | 
| 最終ジャッジ日時 | 2024-09-24 11:19:47 | 
| 合計ジャッジ時間 | 1,240 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 2 | 
ソースコード
#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;
}
            
            
            
        