結果

問題 No.189 SUPER HAPPY DAY
ユーザー ja14378ja14378
提出日時 2021-08-12 08:19:01
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 135 ms / 5,000 ms
コード長 1,315 bytes
コンパイル時間 1,502 ms
コンパイル使用メモリ 115,304 KB
実行使用メモリ 9,456 KB
最終ジャッジ日時 2024-04-08 19:25:16
合計ジャッジ時間 3,346 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
9,456 KB
testcase_01 AC 9 ms
9,456 KB
testcase_02 AC 6 ms
9,456 KB
testcase_03 AC 10 ms
9,456 KB
testcase_04 AC 9 ms
9,456 KB
testcase_05 AC 10 ms
9,456 KB
testcase_06 AC 9 ms
9,456 KB
testcase_07 AC 10 ms
9,456 KB
testcase_08 AC 9 ms
9,456 KB
testcase_09 AC 10 ms
9,456 KB
testcase_10 AC 11 ms
9,456 KB
testcase_11 AC 10 ms
9,456 KB
testcase_12 AC 10 ms
9,456 KB
testcase_13 AC 87 ms
9,456 KB
testcase_14 AC 115 ms
9,344 KB
testcase_15 AC 95 ms
9,456 KB
testcase_16 AC 95 ms
9,456 KB
testcase_17 AC 114 ms
9,344 KB
testcase_18 AC 89 ms
9,456 KB
testcase_19 AC 133 ms
9,344 KB
testcase_20 AC 55 ms
9,344 KB
testcase_21 AC 64 ms
9,456 KB
testcase_22 AC 19 ms
9,456 KB
testcase_23 AC 67 ms
9,456 KB
testcase_24 AC 73 ms
9,344 KB
testcase_25 AC 135 ms
9,344 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <tuple>
#include <cassert>
#include <bitset>
#include <tuple>
#include <stack>
#include<cstring>
using ll = long long;
#define MOD 1000000007
#define Mod 998244353
#define MAX 1000000000
#define INF 10000000000000
using namespace std;

ll dp[205][2][1805];
ll mod = 1000000009;

vector<ll> solve(string S) {
    vector<ll> res(1805, 0);
    int L = (int)S.size();
    for (int i = 0; i < L; i++) {
        int N = S[i]-'0';
        for (int j = 0; j < 2; j++) {
            for (int k = 0; k < 1805; k++) {
                for (int d = 0; d <= (j ? 9 : N); d++) {
                    if (k >= d) dp[i+1][j || (d < N)][k] += dp[i][j][k-d];
                    dp[i+1][j || (d < N)][k] %= mod;
                }
            }
        }
    }
    for (int i = 1; i < 1805; i++) res[i] = (dp[L][0][i]+dp[L][1][i])%mod;
    return res;
}

int main() {
    string M, D;
    cin >> M >> D;
    dp[0][0][0] = 1;
    auto KM = solve(M);
    memset(dp, 0, sizeof(dp));
    dp[0][0][0] = 1;
    auto KD = solve(D);
    ll ans = 0;
    for (int i = 1; i < 1805; i++) {
        ans += (KM[i]*KD[i])%mod;
        ans %= mod;
    }
    cout << ans << endl;
}
0