結果

問題 No.41 貯金箱の溜息(EASY)
ユーザー krotonkroton
提出日時 2014-10-17 00:30:10
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,014 bytes
コンパイル時間 564 ms
コンパイル使用メモリ 71,916 KB
実行使用メモリ 29,432 KB
最終ジャッジ日時 2023-08-28 21:17:28
合計ジャッジ時間 8,655 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <fstream>
#include <sstream>
using namespace std;
typedef long long ll;

const ll MOD = 1000000009ll;

bool done[100000][20];
ll dp[100000][20];

int coin[] = {1, 1, 2, 3, 4, 5, 6, 7, 8, 9};

ll solve(ll k, int last){
    if(k == 0)return 1;
    if(last >= 10)return 0;
    
    if(done[k][last])return dp[k][last];
    
    ll res = 0;
    if(k >= coin[last]){
        res = solve(k - coin[last], last);
        res = (res + solve(k, last + 1)) % MOD;
    }
    
    
    done[k][last] = true;
    return dp[k][last] = res;
}

int main(){
    for(int k=0;k<100000;k++)for(int i=0;i<10;i++)solve(k, i);
    
    int T;
    cin >> T;
    
    while(T--){
        ll M;
        cin >> M;
        
        memset(done, false, sizeof(done));
        cout << solve(M / 111111, 0) << endl;
    }
    
    return 0;
}
0