結果

問題 No.189 SUPER HAPPY DAY
ユーザー 👑 H20H20
提出日時 2021-02-25 10:26:02
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 816 ms / 5,000 ms
コード長 630 bytes
コンパイル時間 253 ms
コンパイル使用メモリ 81,692 KB
実行使用メモリ 134,984 KB
最終ジャッジ日時 2023-10-26 01:04:20
合計ジャッジ時間 8,424 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 65 ms
68,632 KB
testcase_01 AC 87 ms
76,128 KB
testcase_02 AC 68 ms
68,640 KB
testcase_03 AC 79 ms
75,932 KB
testcase_04 AC 83 ms
75,940 KB
testcase_05 AC 81 ms
76,004 KB
testcase_06 AC 87 ms
76,104 KB
testcase_07 AC 86 ms
76,028 KB
testcase_08 AC 84 ms
75,984 KB
testcase_09 AC 84 ms
75,996 KB
testcase_10 AC 85 ms
76,008 KB
testcase_11 AC 85 ms
76,008 KB
testcase_12 AC 81 ms
75,964 KB
testcase_13 AC 402 ms
93,380 KB
testcase_14 AC 518 ms
100,732 KB
testcase_15 AC 482 ms
100,644 KB
testcase_16 AC 478 ms
104,032 KB
testcase_17 AC 561 ms
106,564 KB
testcase_18 AC 451 ms
98,936 KB
testcase_19 AC 654 ms
109,592 KB
testcase_20 AC 272 ms
86,216 KB
testcase_21 AC 314 ms
85,572 KB
testcase_22 AC 110 ms
77,096 KB
testcase_23 AC 461 ms
104,888 KB
testcase_24 AC 451 ms
105,260 KB
testcase_25 AC 816 ms
134,984 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import product

M,D = input().split()
mod = 10**9+9
def count(a):
    n = len(a)
    dp=[[[0] * 1801 for i in range(2)] for j in range(n+1)]
    dp[0][0][0] = 1

    for i, less, ketawa in product(range(n), (0,1), range(1801)):
        max_d = 9 if less else int(a[i])
        for d in range(max_d+1):
            less_ = less or d < max_d
            ketawa_ = ketawa + d
            if ketawa_<=1800:
                dp[i + 1][less_][ketawa_] += dp[i][less][ketawa]

    return dp[n]

ML = count(M)
DL = count(D)

ans = 0
for i in range(1,1801):
    ans += (ML[0][i]+ML[1][i])*(DL[0][i]+DL[1][i])

print(ans%mod)
0