結果

問題 No.189 SUPER HAPPY DAY
ユーザー mkawa2mkawa2
提出日時 2020-01-27 22:35:57
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 2,943 ms / 5,000 ms
コード長 2,505 bytes
コンパイル時間 88 ms
コンパイル使用メモリ 11,248 KB
実行使用メモリ 117,264 KB
最終ジャッジ日時 2023-10-12 17:53:38
合計ジャッジ時間 17,700 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 22 ms
9,156 KB
testcase_01 AC 37 ms
10,904 KB
testcase_02 AC 22 ms
9,000 KB
testcase_03 AC 33 ms
10,408 KB
testcase_04 AC 33 ms
10,580 KB
testcase_05 AC 34 ms
10,740 KB
testcase_06 AC 34 ms
10,580 KB
testcase_07 AC 35 ms
10,784 KB
testcase_08 AC 32 ms
10,412 KB
testcase_09 AC 33 ms
10,588 KB
testcase_10 AC 34 ms
10,716 KB
testcase_11 AC 34 ms
10,712 KB
testcase_12 AC 34 ms
10,736 KB
testcase_13 AC 839 ms
50,000 KB
testcase_14 AC 1,167 ms
62,412 KB
testcase_15 AC 1,230 ms
58,704 KB
testcase_16 AC 1,443 ms
64,116 KB
testcase_17 AC 1,518 ms
69,844 KB
testcase_18 AC 1,172 ms
56,628 KB
testcase_19 AC 1,648 ms
78,196 KB
testcase_20 AC 463 ms
32,216 KB
testcase_21 AC 463 ms
35,000 KB
testcase_22 AC 71 ms
14,396 KB
testcase_23 AC 1,455 ms
63,072 KB
testcase_24 AC 1,456 ms
63,156 KB
testcase_25 AC 2,943 ms
117,264 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

class mint:
    def __init__(self, x):
        self.__x = x % md

    def __str__(self):
        return str(self.__x)

    def __add__(self, other):
        if isinstance(other, mint): other = other.__x
        return mint(self.__x + other)

    def __sub__(self, other):
        if isinstance(other, mint): other = other.__x
        return mint(self.__x - other)

    def __rsub__(self, other):
        return mint(other - self.__x)

    def __mul__(self, other):
        if isinstance(other, mint): other = other.__x
        return mint(self.__x * other)

    __radd__ = __add__
    __rmul__ = __mul__

    def __truediv__(self, other):
        if isinstance(other, mint): other = other.__x
        return mint(self.__x * pow(other, md - 2, md))

    def __pow__(self, power, modulo=None):
        return mint(pow(self.__x, power, md))

md = 10 ** 9 + 9
def main():
    m, d = input().split()
    m = [int(c) for c in m]
    d = [int(c) for c in d]
    dpm = [[[0] * 2 for _ in range(1801)] for _ in range(len(m) + 1)]
    dpd = [[[0] * 2 for _ in range(1801)] for _ in range(len(d) + 1)]
    dpm[0][0][0] = mint(1)
    dpd[0][0][0] = mint(1)
    for i, a in enumerate(m):
        for s in range(1801):
            for f in range(2):
                pre = dpm[i][s][f]
                if pre == 0: continue
                if f:
                    for na in range(10):
                        dpm[i + 1][s + na][1] += pre
                else:
                    for na in range(a):
                        dpm[i + 1][s + na][1] += pre
                    dpm[i + 1][s + a][0] += pre

    for i, a in enumerate(d):
        for s in range(1801):
            for f in range(2):
                pre = dpd[i][s][f]
                if pre == 0: continue
                if f:
                    for na in range(10):
                        dpd[i + 1][s + na][1] += pre
                else:
                    for na in range(a):
                        dpd[i + 1][s + na][1] += pre
                    dpd[i + 1][s + a][0] += pre

    ans = sum(sum(dpm[-1][i]) * sum(dpd[-1][i]) for i in range(1, 1801))
    print(ans)

main()
0