結果

問題 No.189 SUPER HAPPY DAY
ユーザー mkawa2mkawa2
提出日時 2020-01-27 23:02:24
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 1,831 bytes
コンパイル時間 75 ms
コンパイル使用メモリ 10,896 KB
実行使用メモリ 60,128 KB
最終ジャッジ日時 2023-10-12 18:03:59
合計ジャッジ時間 9,201 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
8,488 KB
testcase_01 AC 21 ms
8,572 KB
testcase_02 AC 16 ms
8,404 KB
testcase_03 RE -
testcase_04 RE -
testcase_05 WA -
testcase_06 RE -
testcase_07 WA -
testcase_08 RE -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 RE -
testcase_15 WA -
testcase_16 WA -
testcase_17 RE -
testcase_18 WA -
testcase_19 RE -
testcase_20 RE -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 RE -
testcase_25 AC 2,336 ms
60,128 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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 for _ in range(1801)] for _ in range(len(m) + 1)]
    dpd = [[0 for _ in range(1801)] for _ in range(len(d) + 1)]
    border = 0
    for i, a in enumerate(m):
        for s in range(1801):
            pre = dpm[i][s]
            if pre == 0: continue
            for na in range(10):
                dpm[i + 1][s + na] += pre
        for na in range(a):
            dpm[i + 1][border + na] += mint(1)
        border += a
    dpm[-1][border] += 1

    border = 0
    for i, a in enumerate(m):
        for s in range(1801):
            pre = dpd[i][s]
            if pre == 0: continue
            for na in range(10):
                dpd[i + 1][s + na] += pre
        for na in range(a):
            dpd[i + 1][border + na] += mint(1)
        border += a
    dpd[-1][border] += 1

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

main()
0