結果

問題 No.41 貯金箱の溜息(EASY)
ユーザー Kutimoti_TKutimoti_T
提出日時 2018-01-10 22:15:26
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2,091 ms / 5,000 ms
コード長 976 bytes
コンパイル時間 639 ms
コンパイル使用メモリ 67,600 KB
実行使用メモリ 9,832 KB
最終ジャッジ日時 2023-08-25 10:40:09
合計ジャッジ時間 3,551 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
using namespace std;

typedef long long ll;

#define FOR(i, s, e) for (int i = (s); i <= (e); i++)

#define MOD(N) ((N) % 1000000009)

ll T;

ll M;

ll dp[10][90010];

int main()
{
    FOR(i, 0, 9)
    {
        FOR(j, 0, 9009)
        {
            dp[i][j] = 0;
        }
    }
    dp[0][0] = 1;

    FOR(i, 1, 9)
    {
        FOR(j, 0, 90009)
        {
            if (j - i >= 0)
            {
                dp[i][j] += dp[i - 1][j] + dp[i][j - i];
            }
            else
            {
                dp[i][j] += dp[i - 1][j];
            }
            dp[i][j] = MOD(dp[i][j]);
        }
    }

    cin >> T;

    FOR(c, 0, T - 1)
    {
        cin >> M;

        int N = M / 111111;

        ll result = 0;
        FOR(i, 0, N)
        {
            result = MOD(result + dp[9][i]);
        }

        cout << result << endl;
    }
}
0