結果

問題 No.1085 桁和の桁和
ユーザー tyawanmusityawanmusi
提出日時 2020-01-03 19:05:32
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 311 ms / 2,000 ms
コード長 623 bytes
コンパイル時間 265 ms
コンパイル使用メモリ 87,108 KB
実行使用メモリ 92,612 KB
最終ジャッジ日時 2023-08-06 14:26:35
合計ジャッジ時間 7,970 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,216 KB
testcase_01 AC 71 ms
71,068 KB
testcase_02 AC 71 ms
71,272 KB
testcase_03 AC 77 ms
71,168 KB
testcase_04 AC 302 ms
92,012 KB
testcase_05 AC 73 ms
70,960 KB
testcase_06 AC 71 ms
70,992 KB
testcase_07 AC 75 ms
71,200 KB
testcase_08 AC 75 ms
71,068 KB
testcase_09 AC 76 ms
71,356 KB
testcase_10 AC 76 ms
71,112 KB
testcase_11 AC 76 ms
71,196 KB
testcase_12 AC 83 ms
76,392 KB
testcase_13 AC 103 ms
76,596 KB
testcase_14 AC 135 ms
80,156 KB
testcase_15 AC 190 ms
84,100 KB
testcase_16 AC 190 ms
84,072 KB
testcase_17 AC 135 ms
80,236 KB
testcase_18 AC 112 ms
76,636 KB
testcase_19 AC 179 ms
83,440 KB
testcase_20 AC 181 ms
83,364 KB
testcase_21 AC 147 ms
81,004 KB
testcase_22 AC 163 ms
82,672 KB
testcase_23 AC 91 ms
76,588 KB
testcase_24 AC 81 ms
76,268 KB
testcase_25 AC 138 ms
80,492 KB
testcase_26 AC 189 ms
84,332 KB
testcase_27 AC 166 ms
82,756 KB
testcase_28 AC 199 ms
85,224 KB
testcase_29 AC 146 ms
81,284 KB
testcase_30 AC 141 ms
80,932 KB
testcase_31 AC 186 ms
83,860 KB
testcase_32 AC 158 ms
81,776 KB
testcase_33 AC 311 ms
92,612 KB
testcase_34 AC 301 ms
92,572 KB
testcase_35 AC 307 ms
92,416 KB
testcase_36 AC 301 ms
92,584 KB
testcase_37 AC 307 ms
92,360 KB
testcase_38 AC 305 ms
92,504 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

s=input()
d=int(input())
mod=10**9+7
digit_sum=0
blind_count=0
for i in range(len(s)):
  if s[i]=="?":
    blind_count+=1
  else:
    digit_sum+=int(s[i])
    while digit_sum>9:
      digit_sum-=9

dp=[10*[0]for _ in range(blind_count+1)]
dp[0][0]=1
for i in range(1,blind_count+1):
  for j in range(10):
    for k in range(10):
      jk=j+k
      if jk>9:
        jk-=9
      dp[i][jk]+=dp[i-1][j]
      dp[i][jk]%=mod

if d==0:
    if digit_sum==0:
        print(1)
    else:
        print(0)
    exit()

if digit_sum<d:
    n=d-digit_sum
else:
    n=d-digit_sum+9
ans=dp[blind_count][n]
if digit_sum==d:ans+=1
print(ans)
0