結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
9,896 KB
testcase_01 AC 8 ms
9,724 KB
testcase_02 AC 4 ms
9,844 KB
testcase_03 AC 9 ms
9,824 KB
testcase_04 AC 8 ms
9,920 KB
testcase_05 AC 8 ms
9,740 KB
testcase_06 AC 8 ms
9,764 KB
testcase_07 AC 8 ms
9,728 KB
testcase_08 AC 8 ms
9,712 KB
testcase_09 AC 9 ms
10,000 KB
testcase_10 AC 9 ms
9,704 KB
testcase_11 AC 9 ms
9,912 KB
testcase_12 AC 8 ms
9,744 KB
testcase_13 AC 224 ms
10,028 KB
testcase_14 AC 287 ms
9,880 KB
testcase_15 AC 244 ms
9,872 KB
testcase_16 AC 242 ms
9,784 KB
testcase_17 AC 287 ms
9,764 KB
testcase_18 AC 232 ms
9,820 KB
testcase_19 AC 360 ms
9,816 KB
testcase_20 AC 124 ms
10,040 KB
testcase_21 AC 152 ms
9,724 KB
testcase_22 AC 32 ms
9,744 KB
testcase_23 AC 193 ms
9,820 KB
testcase_24 AC 192 ms
9,988 KB
testcase_25 AC 385 ms
9,788 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// Wrongri-La Shower

#include <iostream>
#include <cstring>

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

int rec(int digit, bool free, int rest, int (&dp)[205][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