結果

問題 No.1085 桁和の桁和
ユーザー googol_S0googol_S0
提出日時 2020-06-19 21:45:14
言語 PyPy3
(7.3.13)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 529 bytes
コンパイル時間 607 ms
コンパイル使用メモリ 86,856 KB
実行使用メモリ 92,256 KB
最終ジャッジ日時 2023-09-30 06:03:00
合計ジャッジ時間 5,181 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 67 ms
71,180 KB
testcase_01 AC 64 ms
71,044 KB
testcase_02 AC 67 ms
71,348 KB
testcase_03 AC 69 ms
71,044 KB
testcase_04 AC 70 ms
75,808 KB
testcase_05 AC 67 ms
71,196 KB
testcase_06 AC 66 ms
71,136 KB
testcase_07 AC 66 ms
71,048 KB
testcase_08 AC 67 ms
71,416 KB
testcase_09 AC 66 ms
71,128 KB
testcase_10 AC 62 ms
71,216 KB
testcase_11 WA -
testcase_12 AC 67 ms
71,044 KB
testcase_13 AC 81 ms
78,652 KB
testcase_14 AC 94 ms
83,048 KB
testcase_15 AC 113 ms
90,168 KB
testcase_16 AC 111 ms
90,032 KB
testcase_17 AC 95 ms
83,188 KB
testcase_18 AC 83 ms
80,316 KB
testcase_19 AC 106 ms
89,040 KB
testcase_20 AC 60 ms
71,200 KB
testcase_21 AC 95 ms
84,668 KB
testcase_22 AC 103 ms
88,028 KB
testcase_23 AC 79 ms
76,876 KB
testcase_24 AC 73 ms
76,584 KB
testcase_25 AC 94 ms
84,324 KB
testcase_26 AC 121 ms
91,916 KB
testcase_27 AC 104 ms
87,956 KB
testcase_28 AC 121 ms
92,104 KB
testcase_29 AC 97 ms
85,380 KB
testcase_30 AC 99 ms
84,880 KB
testcase_31 AC 121 ms
89,920 KB
testcase_32 AC 109 ms
86,164 KB
testcase_33 AC 124 ms
92,152 KB
testcase_34 AC 125 ms
92,084 KB
testcase_35 AC 123 ms
92,132 KB
testcase_36 AC 121 ms
92,256 KB
testcase_37 AC 118 ms
91,960 KB
testcase_38 AC 122 ms
92,208 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','?'} or set(T)==set('?')):
  DP[N][D%9]=(DP[N][D%9]-1)%mod
print(DP[N][D%9])
0