結果

問題 No.1085 桁和の桁和
ユーザー googol_S0googol_S0
提出日時 2020-06-19 21:41:41
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 507 bytes
コンパイル時間 343 ms
コンパイル使用メモリ 86,888 KB
実行使用メモリ 92,568 KB
最終ジャッジ日時 2023-09-30 06:02:24
合計ジャッジ時間 5,435 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 68 ms
71,212 KB
testcase_01 AC 67 ms
71,212 KB
testcase_02 AC 68 ms
71,084 KB
testcase_03 AC 66 ms
71,176 KB
testcase_04 AC 74 ms
75,632 KB
testcase_05 AC 70 ms
71,080 KB
testcase_06 AC 68 ms
71,192 KB
testcase_07 AC 67 ms
71,200 KB
testcase_08 AC 67 ms
71,196 KB
testcase_09 WA -
testcase_10 AC 61 ms
71,228 KB
testcase_11 WA -
testcase_12 AC 78 ms
71,352 KB
testcase_13 AC 91 ms
78,928 KB
testcase_14 AC 104 ms
82,968 KB
testcase_15 AC 122 ms
89,936 KB
testcase_16 AC 118 ms
89,948 KB
testcase_17 AC 103 ms
83,188 KB
testcase_18 AC 90 ms
80,404 KB
testcase_19 AC 118 ms
89,040 KB
testcase_20 AC 67 ms
71,156 KB
testcase_21 AC 105 ms
84,800 KB
testcase_22 AC 114 ms
87,908 KB
testcase_23 AC 85 ms
76,624 KB
testcase_24 AC 80 ms
76,484 KB
testcase_25 AC 105 ms
84,304 KB
testcase_26 AC 130 ms
91,116 KB
testcase_27 AC 113 ms
88,168 KB
testcase_28 AC 120 ms
91,904 KB
testcase_29 AC 103 ms
85,824 KB
testcase_30 AC 102 ms
84,904 KB
testcase_31 AC 116 ms
90,028 KB
testcase_32 AC 103 ms
86,276 KB
testcase_33 AC 124 ms
92,212 KB
testcase_34 AC 125 ms
92,208 KB
testcase_35 AC 124 ms
92,228 KB
testcase_36 AC 125 ms
92,176 KB
testcase_37 AC 121 ms
92,568 KB
testcase_38 AC 120 ms
92,172 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

T=input()
N=len(T)
D=int(input())
mod=10**9+7
if D==0:
  for i in range(N):
    if T[i]!='0' and T[i]!='?':
      print(0)
      exit()
  print(1)
  exit()
if set(T)==set([0]):
  print(0)
  exit()
DP=[[0]*9 for i in range(N+1)]
DP[0][0]=1
x=0
for i in range(N):
  if T[i]=='?':
    x=sum(DP[i])%mod
    for j in range(9):
      DP[i+1][j]=(x+DP[i][j])%mod
  else:
    for j in range(9):
      DP[i+1][(j+int(T[i]))%9]=DP[i][j]
if D==9 and set(T)=={'0','?'}:
  DP[N][D%9]=(DP[N][D%9]-1)%mod
print(DP[N][D%9])
0