結果

問題 No.189 SUPER HAPPY DAY
ユーザー srjywrdnprktsrjywrdnprkt
提出日時 2023-01-15 20:19:57
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 96 ms / 5,000 ms
コード長 1,264 bytes
コンパイル時間 1,095 ms
コンパイル使用メモリ 116,384 KB
実行使用メモリ 23,248 KB
最終ジャッジ日時 2023-08-28 12:42:11
合計ジャッジ時間 2,932 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 5 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 5 ms
4,376 KB
testcase_04 AC 5 ms
4,380 KB
testcase_05 AC 5 ms
4,380 KB
testcase_06 AC 4 ms
4,380 KB
testcase_07 AC 5 ms
4,380 KB
testcase_08 AC 4 ms
4,376 KB
testcase_09 AC 6 ms
4,376 KB
testcase_10 AC 5 ms
4,376 KB
testcase_11 AC 5 ms
4,376 KB
testcase_12 AC 5 ms
4,376 KB
testcase_13 AC 53 ms
15,808 KB
testcase_14 AC 69 ms
16,036 KB
testcase_15 AC 57 ms
20,784 KB
testcase_16 AC 60 ms
22,684 KB
testcase_17 AC 71 ms
22,096 KB
testcase_18 AC 55 ms
20,316 KB
testcase_19 AC 83 ms
18,892 KB
testcase_20 AC 33 ms
13,728 KB
testcase_21 AC 39 ms
12,112 KB
testcase_22 AC 11 ms
5,792 KB
testcase_23 AC 50 ms
23,220 KB
testcase_24 AC 50 ms
23,128 KB
testcase_25 AC 96 ms
23,248 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <iomanip>
#include <queue>
#include <algorithm>
#include <numeric>
#include <deque>
#include <complex>
#include <cassert>

using namespace std;

const long long modc = 1e9+9;

vector<long long> f(string &X){
    int N = X.size();
    vector<vector<vector<long long>>> pd(N+1, vector(1801, vector<long long>(2)));
    pd[0][0][1] = 1;

    for (int i=1; i<=N; i++){
        for (int j=0; j<=1800; j++){
            if (j-(X[i-1]-'0')>=0) pd[i][j][1] = pd[i-1][j-(X[i-1]-'0')][1];
            for (int k=0; k<=9; k++) if (j>=k){
                pd[i][j][0] += pd[i-1][j-k][0];
                pd[i][j][0] %= modc;
            }
            for (int k=0; k<X[i-1]-'0'; k++) if (j>=k){
                pd[i][j][0] += pd[i-1][j-k][1];
                pd[i][j][0] %= modc;
            }
        }
    }
    vector<long long> dp(1801);
    for (int i=0; i<=1800; i++) dp[i] = (pd[N][i][0] + pd[N][i][1]) % modc;
    return dp;
}

int main(){

    long long ans=0;
    string M, D;
    cin >> M >> D;
    vector<long long> dpm, dpd;
    dpm = f(M); dpd = f(D);

    for (int i=1; i<=1800; i++) ans = (ans + dpm[i]*dpd[i]%modc) % modc;

    cout << ans << endl;

    return 0;
}
0