結果
| 問題 | No.189 SUPER HAPPY DAY |
| コンテスト | |
| ユーザー |
maspy
|
| 提出日時 | 2020-03-04 11:10:58 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 510 ms / 5,000 ms |
| コード長 | 998 bytes |
| コンパイル時間 | 190 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 44,500 KB |
| 最終ジャッジ日時 | 2024-10-13 23:37:11 |
| 合計ジャッジ時間 | 14,060 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 23 |
ソースコード
#!/usr/bin/env python3
# %%
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np
MOD = 10 ** 9 + 9
max_sum = 9 * 200 + 10
# %%
M, D = map(list, read().split())
M = [x - ord('0') for x in M]
D = [x - ord('0') for x in D]
# %%
def make_sum_dist(A):
dp_1 = np.zeros(max_sum, np.int64)
dp_2 = np.zeros_like(dp_1)
dp_1[0] = 1
for x in A:
newdp_1 = np.zeros_like(dp_1)
newdp_2 = np.zeros_like(dp_2)
for i in range(x + 1):
newdp_1[i:] += dp_1[: max_sum - i]
for i in range(x + 1, 10):
newdp_1[i:] += dp_2[: max_sum - i]
for i in range(x):
newdp_2[i:] += dp_1[: max_sum - i]
for i in range(x, 10):
newdp_2[i:] += dp_2[: max_sum - i]
dp_1 = newdp_1 % MOD
dp_2 = newdp_2 % MOD
return dp_1
# %%
x = make_sum_dist(M)
x *= make_sum_dist(D)
x %= MOD
answer = x[1:].sum() % MOD
print(answer)
maspy