結果

問題 No.1085 桁和の桁和
ユーザー wolgnikwolgnik
提出日時 2020-06-19 22:21:56
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 952 ms / 2,000 ms
コード長 562 bytes
コンパイル時間 1,043 ms
コンパイル使用メモリ 86,908 KB
実行使用メモリ 96,912 KB
最終ジャッジ日時 2023-08-06 14:32:27
合計ジャッジ時間 16,248 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,152 KB
testcase_01 AC 71 ms
71,192 KB
testcase_02 AC 71 ms
71,440 KB
testcase_03 AC 74 ms
71,196 KB
testcase_04 AC 844 ms
95,880 KB
testcase_05 AC 72 ms
71,276 KB
testcase_06 AC 72 ms
71,100 KB
testcase_07 AC 73 ms
71,416 KB
testcase_08 AC 74 ms
71,260 KB
testcase_09 AC 72 ms
71,496 KB
testcase_10 AC 70 ms
71,108 KB
testcase_11 AC 72 ms
71,456 KB
testcase_12 AC 84 ms
76,456 KB
testcase_13 AC 156 ms
80,012 KB
testcase_14 AC 274 ms
85,564 KB
testcase_15 AC 504 ms
94,016 KB
testcase_16 AC 481 ms
93,852 KB
testcase_17 AC 283 ms
85,608 KB
testcase_18 AC 199 ms
81,504 KB
testcase_19 AC 470 ms
92,268 KB
testcase_20 AC 461 ms
92,180 KB
testcase_21 AC 333 ms
87,472 KB
testcase_22 AC 451 ms
90,856 KB
testcase_23 AC 134 ms
78,276 KB
testcase_24 AC 102 ms
77,300 KB
testcase_25 AC 306 ms
86,888 KB
testcase_26 AC 508 ms
94,504 KB
testcase_27 AC 438 ms
91,076 KB
testcase_28 AC 558 ms
96,680 KB
testcase_29 AC 360 ms
87,760 KB
testcase_30 AC 320 ms
87,648 KB
testcase_31 AC 477 ms
93,540 KB
testcase_32 AC 372 ms
89,012 KB
testcase_33 AC 952 ms
96,692 KB
testcase_34 AC 910 ms
96,912 KB
testcase_35 AC 937 ms
96,576 KB
testcase_36 AC 903 ms
96,796 KB
testcase_37 AC 932 ms
96,808 KB
testcase_38 AC 916 ms
96,724 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
S = list(input())[: -1]
D = int(input())
mod = 10 ** 9 + 7
dp = [[0] * (10) for _ in range(len(S) + 1)]
dp[0][0] = 1

def digitsum(x):
  if x <= 9: return x
  s = str(x)
  y = 0
  for i in s: y += int(i)
  return digitsum(y)

for i in range(len(S)):
  for j in range(10):
    if S[i] != "?":
      x = digitsum(j + int(S[i]))
      dp[i + 1][x] += dp[i][j]
      dp[i + 1][x] %= mod
    else:
      for k in range(10):
        x = digitsum(j + k)
        dp[i + 1][x] += dp[i][j]
        dp[i + 1][x] %= mod
print(dp[-1][D])
0