結果

問題 No.41 貯金箱の溜息(EASY)
ユーザー krotonkroton
提出日時 2014-10-16 23:42:40
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,025 bytes
コンパイル時間 565 ms
コンパイル使用メモリ 72,000 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-08-28 21:15:32
合計ジャッジ時間 998 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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;
int coin[] = {1, 1, 2, 3, 4, 5, 6, 7, 8, 9};

ll dp[100000][20];
ll solve(ll K){
    memset(dp, 0, sizeof(dp));
    
    dp[0][0] = 1;
    
    for(int k=0;k<K;k++){
        for(int last=0;last<10;last++){
            int add = coin[last];
            dp[k+add][last] = (dp[k+add][last] + dp[k][last]) % MOD;
            dp[k][last+1] = (dp[k][last+1] + dp[k][last]) % MOD;
        }
    }
    
    ll res = 0;
    for(int i=0;i<10;i++)res = (res + dp[K][i]) % MOD;
    return res;
}

int main(){
    ifstream cin("/Users/user/Desktop/yukicoder/41/input.txt");
    
    int T;
    cin >> T;
    
    while(T--){
        ll M;
        cin >> M;
        
        cout << solve(M / 111111) << endl;
    }
    
    return 0;
}
0