結果

問題 No.189 SUPER HAPPY DAY
ユーザー tottoripapertottoripaper
提出日時 2015-04-22 01:13:19
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 852 bytes
コンパイル時間 398 ms
コンパイル使用メモリ 53,660 KB
実行使用メモリ 9,808 KB
最終ジャッジ日時 2023-09-18 07:14:35
合計ジャッジ時間 4,184 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
9,600 KB
testcase_01 AC 7 ms
9,556 KB
testcase_02 AC 4 ms
9,640 KB
testcase_03 AC 8 ms
9,572 KB
testcase_04 AC 8 ms
9,564 KB
testcase_05 AC 8 ms
9,580 KB
testcase_06 AC 8 ms
9,556 KB
testcase_07 AC 9 ms
9,560 KB
testcase_08 AC 8 ms
9,564 KB
testcase_09 AC 9 ms
9,580 KB
testcase_10 AC 9 ms
9,764 KB
testcase_11 AC 10 ms
9,552 KB
testcase_12 AC 9 ms
9,660 KB
testcase_13 AC 223 ms
9,648 KB
testcase_14 AC 288 ms
9,808 KB
testcase_15 AC 243 ms
9,596 KB
testcase_16 AC 241 ms
9,676 KB
testcase_17 AC 287 ms
9,620 KB
testcase_18 AC 233 ms
9,596 KB
testcase_19 AC 361 ms
9,628 KB
testcase_20 AC 123 ms
9,592 KB
testcase_21 AC 152 ms
9,572 KB
testcase_22 AC 33 ms
9,632 KB
testcase_23 AC 193 ms
9,676 KB
testcase_24 RE -
testcase_25 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

// Wrongri-La Shower

#include <iostream>
#include <cstring>

std::string M, D;
int dp[200][2][2000], dp2[200][2][2000];
const int MOD = 1000000009;

int rec(int digit, bool free, int rest, int (&dp)[200][2][2000], const std::string str){
    if(digit == str.size()){return rest == 0;}
    auto &res = dp[digit][free][rest];
    if(res != -1){return res;}

    res = 0;
    for(int i=0;i<=(free?9:str[digit]-'0');i++){
        if(rest < i){continue;}
        res = (res + rec(digit+1, free | (i != str[digit]-'0'), rest - i, dp, str)) % MOD;
    }

    return res;
}

int main(){
    std::cin >> M >> D;

    memset(dp, -1, sizeof(dp));
    memset(dp2, -1, sizeof(dp2));
    
    long long res = 0ll;
    for(int i=1;i<2000;i++){
        res = (1ll * rec(0, 0, i, dp, M) * rec(0, 0, i, dp2, D) + res) % MOD;
    }

    std::cout << res << std::endl;
}
0