結果
問題 | No.189 SUPER HAPPY DAY |
ユーザー |
![]() |
提出日時 | 2020-01-27 22:35:57 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 3,265 ms / 5,000 ms |
コード長 | 2,505 bytes |
コンパイル時間 | 185 ms |
コンパイル使用メモリ | 12,928 KB |
実行使用メモリ | 113,920 KB |
最終ジャッジ日時 | 2024-09-14 16:23:22 |
合計ジャッジ時間 | 19,470 ms |
ジャッジサーバーID (参考情報) |
judge6 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 23 |
ソースコード
import syssys.setrecursionlimit(10 ** 6)int1 = lambda x: int(x) - 1p2D = 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 % mddef __str__(self):return str(self.__x)def __add__(self, other):if isinstance(other, mint): other = other.__xreturn mint(self.__x + other)def __sub__(self, other):if isinstance(other, mint): other = other.__xreturn mint(self.__x - other)def __rsub__(self, other):return mint(other - self.__x)def __mul__(self, other):if isinstance(other, mint): other = other.__xreturn mint(self.__x * other)__radd__ = __add____rmul__ = __mul__def __truediv__(self, other):if isinstance(other, mint): other = other.__xreturn mint(self.__x * pow(other, md - 2, md))def __pow__(self, power, modulo=None):return mint(pow(self.__x, power, md))md = 10 ** 9 + 9def 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: continueif f:for na in range(10):dpm[i + 1][s + na][1] += preelse:for na in range(a):dpm[i + 1][s + na][1] += predpm[i + 1][s + a][0] += prefor i, a in enumerate(d):for s in range(1801):for f in range(2):pre = dpd[i][s][f]if pre == 0: continueif f:for na in range(10):dpd[i + 1][s + na][1] += preelse:for na in range(a):dpd[i + 1][s + na][1] += predpd[i + 1][s + a][0] += preans = sum(sum(dpm[-1][i]) * sum(dpd[-1][i]) for i in range(1, 1801))print(ans)main()