結果
| 問題 | No.41 貯金箱の溜息(EASY) | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2017-07-03 17:26:00 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 1,839 ms / 5,000 ms | 
| コード長 | 1,441 bytes | 
| コンパイル時間 | 1,767 ms | 
| コンパイル使用メモリ | 166,664 KB | 
| 実行使用メモリ | 17,500 KB | 
| 最終ジャッジ日時 | 2024-10-05 12:28:44 | 
| 合計ジャッジ時間 | 3,800 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 2 | 
ソースコード
#include <bits/stdc++.h>
#define show(x) cout << #x << " = " << x << endl
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v)
{
    os << "sz=" << v.size() << "\n[";
    for (const auto& p : v) {
        os << p << ",";
    }
    os << "]\n";
    return os;
}
template <typename S, typename T>
ostream& operator<<(ostream& os, const pair<S, T>& p)
{
    os << "(" << p.first << "," << p.second
       << ")";
    return os;
}
constexpr ll MOD = 1e9 + 9;
template <typename T>
constexpr T INF = numeric_limits<T>::max() / 100;
constexpr ll MAX = (10000000000 / 111111);
ll dp[10][MAX + 1];  // i番目まででy円
ll sum[10][MAX + 1];
int main()
{
    dp[0][0] = 1;
    for (ll y = 0; y <= MAX; y++) {
        sum[0][y] = 1;
    }
    for (ll i = 1; i <= 9; i++) {
        for (ll y = 0; y <= MAX; y++) {
            dp[i][y] = sum[i - 1][y];
            if (y >= i + 1) {
                sum[i][y] = (sum[i][y - (i + 1)] + dp[i][y]) % MOD;
            } else {
                sum[i][y] = dp[i][y];
            }
        }
    }
    ll T;
    cin >> T;
    for (ll t = 0; t < T; t++) {
        ll M;
        cin >> M;
        const ll m = M / 111111;
        ll sum = 0;
        for (ll y = 0; y <= m; y++) {
            sum = (sum + dp[9][y]) % MOD;
        }
        cout << sum << endl;
    }
    return 0;
}
            
            
            
        