結果

問題 No.189 SUPER HAPPY DAY
ユーザー 👑 rin204rin204
提出日時 2022-11-03 01:09:56
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 104 ms / 5,000 ms
コード長 679 bytes
コンパイル時間 288 ms
コンパイル使用メモリ 87,180 KB
実行使用メモリ 76,756 KB
最終ジャッジ日時 2023-09-24 11:49:17
合計ジャッジ時間 3,957 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,412 KB
testcase_01 AC 72 ms
75,884 KB
testcase_02 AC 67 ms
71,056 KB
testcase_03 AC 71 ms
75,704 KB
testcase_04 AC 75 ms
75,648 KB
testcase_05 AC 71 ms
75,536 KB
testcase_06 AC 74 ms
75,560 KB
testcase_07 AC 72 ms
75,844 KB
testcase_08 AC 70 ms
75,512 KB
testcase_09 AC 72 ms
75,748 KB
testcase_10 AC 71 ms
75,760 KB
testcase_11 AC 72 ms
75,996 KB
testcase_12 AC 73 ms
75,772 KB
testcase_13 AC 83 ms
76,160 KB
testcase_14 AC 87 ms
76,412 KB
testcase_15 AC 86 ms
76,008 KB
testcase_16 AC 87 ms
76,264 KB
testcase_17 AC 88 ms
76,460 KB
testcase_18 AC 85 ms
76,088 KB
testcase_19 AC 92 ms
76,496 KB
testcase_20 AC 77 ms
76,004 KB
testcase_21 AC 80 ms
75,960 KB
testcase_22 AC 74 ms
75,644 KB
testcase_23 AC 84 ms
76,248 KB
testcase_24 AC 84 ms
76,000 KB
testcase_25 AC 104 ms
76,756 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD = 1000000009

m, d = input().split()

def digit_sum(S):
    n = len(S)
    dp = [0] * (9 * n + 1)
    s = int(S[0])
    eq = s
    for i in range(1, s):
        dp[i] = 1

    for ii, s in enumerate(S[1:], 1):
        s = int(s)
        ndp = [0] * (9 * n + 1)
        for i in range(10):
            for j in range(9 * ii + 1):
                ndp[i + j] += dp[j]
                ndp[i + j] %= MOD
        
        for i in range(1, 10):
            ndp[i] += 1

        for i in range(s):
            ndp[eq + i] += 1

        eq += s
        dp = ndp

    dp[eq] += 1
    return dp

A = digit_sum(m)
B = digit_sum(d)
ans = sum(a * b for a, b in zip(A, B)) % MOD
print(ans)
0