結果

問題 No.189 SUPER HAPPY DAY
ユーザー tktk_snsntktk_snsn
提出日時 2021-01-05 20:42:59
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 627 ms / 5,000 ms
コード長 899 bytes
コンパイル時間 274 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 147,328 KB
最終ジャッジ日時 2024-04-24 00:03:42
合計ジャッジ時間 7,773 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 82 ms
74,240 KB
testcase_01 AC 105 ms
79,360 KB
testcase_02 AC 82 ms
74,240 KB
testcase_03 AC 98 ms
77,568 KB
testcase_04 AC 99 ms
77,824 KB
testcase_05 AC 101 ms
77,440 KB
testcase_06 AC 99 ms
77,312 KB
testcase_07 AC 104 ms
77,952 KB
testcase_08 AC 101 ms
77,696 KB
testcase_09 AC 102 ms
77,312 KB
testcase_10 AC 99 ms
77,312 KB
testcase_11 AC 100 ms
77,696 KB
testcase_12 AC 99 ms
77,952 KB
testcase_13 AC 389 ms
109,952 KB
testcase_14 AC 445 ms
118,656 KB
testcase_15 AC 400 ms
112,384 KB
testcase_16 AC 382 ms
113,536 KB
testcase_17 AC 467 ms
119,680 KB
testcase_18 AC 383 ms
111,104 KB
testcase_19 AC 527 ms
127,488 KB
testcase_20 AC 258 ms
96,000 KB
testcase_21 AC 305 ms
100,224 KB
testcase_22 AC 138 ms
82,560 KB
testcase_23 AC 351 ms
111,744 KB
testcase_24 AC 367 ms
112,384 KB
testcase_25 AC 627 ms
147,328 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 10 ** 9 + 9
U = 2020


def F(A):
    N = len(A)
    dp = [[[0] * 2 for _ in range(U + 1)] for _ in range(N + 1)]
    dp[0][0][0] = 1
    for i, nd in enumerate(A):
        nd = int(nd)
        for j in range(U):
            for k in range(2):
                for d in range(10):
                    ni = i + 1
                    nj = j + d
                    nk = k
                    if nj > U:
                        break
                    if nk == 0:
                        if d > nd:
                            continue
                        if d < nd:
                            nk = 1
                    dp[ni][nj][nk] += dp[i][j][k]
                    dp[ni][nj][nk] %= mod
    res = [(dp[N][i][0] + dp[N][i][1]) % mod for i in range(1, U)]
    return res


M, D = input().split()
M = F(M)
D = F(D)
ans = 0
for m, d in zip(M, D):
    ans += m * d
    ans %= mod
print(ans)
0