結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 62 ms
71,332 KB
testcase_01 AC 63 ms
71,192 KB
testcase_02 AC 61 ms
71,208 KB
testcase_03 AC 64 ms
71,244 KB
testcase_04 AC 66 ms
75,888 KB
testcase_05 AC 69 ms
71,288 KB
testcase_06 AC 65 ms
71,156 KB
testcase_07 AC 67 ms
71,048 KB
testcase_08 AC 64 ms
70,956 KB
testcase_09 WA -
testcase_10 AC 65 ms
71,196 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 83 ms
78,768 KB
testcase_14 AC 95 ms
83,020 KB
testcase_15 AC 112 ms
90,096 KB
testcase_16 AC 118 ms
89,944 KB
testcase_17 AC 95 ms
83,448 KB
testcase_18 AC 87 ms
80,304 KB
testcase_19 AC 111 ms
88,880 KB
testcase_20 AC 64 ms
71,468 KB
testcase_21 AC 97 ms
84,912 KB
testcase_22 AC 107 ms
87,672 KB
testcase_23 AC 79 ms
76,656 KB
testcase_24 AC 74 ms
76,532 KB
testcase_25 AC 99 ms
84,224 KB
testcase_26 AC 122 ms
90,468 KB
testcase_27 AC 109 ms
87,952 KB
testcase_28 AC 118 ms
92,112 KB
testcase_29 AC 100 ms
85,608 KB
testcase_30 AC 100 ms
84,672 KB
testcase_31 AC 110 ms
89,840 KB
testcase_32 AC 102 ms
86,208 KB
testcase_33 AC 121 ms
91,916 KB
testcase_34 AC 119 ms
92,248 KB
testcase_35 AC 117 ms
92,152 KB
testcase_36 AC 122 ms
92,144 KB
testcase_37 AC 116 ms
92,168 KB
testcase_38 AC 114 ms
92,140 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]
print(DP[N][D%9])
0