結果

問題 No.1085 桁和の桁和
ユーザー wolgnikwolgnik
提出日時 2020-06-19 22:21:56
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,037 ms / 2,000 ms
コード長 562 bytes
コンパイル時間 220 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 95,960 KB
最終ジャッジ日時 2024-04-24 10:05:58
合計ジャッジ時間 16,435 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
51,712 KB
testcase_01 AC 42 ms
51,712 KB
testcase_02 AC 42 ms
52,096 KB
testcase_03 AC 45 ms
53,120 KB
testcase_04 AC 963 ms
94,736 KB
testcase_05 AC 41 ms
52,352 KB
testcase_06 AC 42 ms
52,096 KB
testcase_07 AC 42 ms
52,480 KB
testcase_08 AC 42 ms
51,968 KB
testcase_09 AC 41 ms
51,968 KB
testcase_10 AC 41 ms
51,712 KB
testcase_11 AC 42 ms
52,096 KB
testcase_12 AC 58 ms
64,128 KB
testcase_13 AC 148 ms
78,720 KB
testcase_14 AC 272 ms
83,840 KB
testcase_15 AC 531 ms
92,768 KB
testcase_16 AC 517 ms
92,372 KB
testcase_17 AC 295 ms
84,736 KB
testcase_18 AC 194 ms
80,640 KB
testcase_19 AC 493 ms
91,204 KB
testcase_20 AC 493 ms
91,324 KB
testcase_21 AC 332 ms
86,528 KB
testcase_22 AC 450 ms
89,740 KB
testcase_23 AC 118 ms
77,184 KB
testcase_24 AC 85 ms
76,416 KB
testcase_25 AC 307 ms
85,888 KB
testcase_26 AC 545 ms
93,584 KB
testcase_27 AC 446 ms
90,264 KB
testcase_28 AC 591 ms
95,688 KB
testcase_29 AC 373 ms
86,848 KB
testcase_30 AC 320 ms
86,784 KB
testcase_31 AC 506 ms
92,904 KB
testcase_32 AC 393 ms
87,936 KB
testcase_33 AC 1,014 ms
95,584 KB
testcase_34 AC 1,025 ms
95,580 KB
testcase_35 AC 1,025 ms
95,832 KB
testcase_36 AC 1,037 ms
95,576 KB
testcase_37 AC 1,006 ms
95,576 KB
testcase_38 AC 1,031 ms
95,960 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