結果

問題 No.189 SUPER HAPPY DAY
ユーザー 👑 H20H20
提出日時 2021-04-29 18:18:27
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 849 ms / 5,000 ms
コード長 747 bytes
コンパイル時間 741 ms
コンパイル使用メモリ 87,172 KB
実行使用メモリ 144,092 KB
最終ジャッジ日時 2023-09-23 03:02:15
合計ジャッジ時間 11,533 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 93 ms
76,976 KB
testcase_01 AC 109 ms
77,988 KB
testcase_02 AC 96 ms
76,868 KB
testcase_03 AC 102 ms
77,740 KB
testcase_04 AC 106 ms
78,064 KB
testcase_05 AC 109 ms
77,928 KB
testcase_06 AC 112 ms
78,016 KB
testcase_07 AC 111 ms
77,760 KB
testcase_08 AC 105 ms
77,844 KB
testcase_09 AC 108 ms
78,068 KB
testcase_10 AC 107 ms
77,800 KB
testcase_11 AC 106 ms
77,824 KB
testcase_12 AC 104 ms
77,772 KB
testcase_13 AC 435 ms
98,468 KB
testcase_14 AC 533 ms
105,660 KB
testcase_15 AC 499 ms
105,152 KB
testcase_16 AC 501 ms
109,176 KB
testcase_17 AC 583 ms
112,660 KB
testcase_18 AC 456 ms
104,064 KB
testcase_19 AC 666 ms
116,052 KB
testcase_20 AC 299 ms
89,624 KB
testcase_21 AC 332 ms
88,768 KB
testcase_22 AC 132 ms
79,016 KB
testcase_23 AC 475 ms
109,912 KB
testcase_24 AC 479 ms
110,604 KB
testcase_25 AC 849 ms
144,092 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import product

M,D = map(int, input().split())

def count(x):
    a = str(x)
    n = len(a)
    #配列は末から
    #数字和は制約から2000を超えることはない
    dp=[[[0] * 2100 for _ in range(2)] for _ in range(n+1)]
    dp[0][0][0] = 1

    #条件に合わせてDP
    for i, less, suujiwa in product(range(n), (0,1), range(2000)):
        max_d = 9 if less else int(a[i])
        for d in range(max_d+1):
            less_ = less or d < max_d
            suujiwa_ = suujiwa + d
            dp[i + 1][less_][suujiwa_] += dp[i][less][suujiwa]

    return dp[n]
m = count(M)
d = count(D)

ret = 0
for i in range(1,2000):
    ret += (m[False][i]+m[True][i])*(d[False][i]+d[True][i])
mod = 10**9+9
print(ret%mod)
0