結果

問題 No.1085 桁和の桁和
ユーザー tyawanmusityawanmusi
提出日時 2020-05-20 01:01:30
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 659 bytes
コンパイル時間 478 ms
コンパイル使用メモリ 86,940 KB
実行使用メモリ 92,600 KB
最終ジャッジ日時 2023-09-30 06:00:47
合計ジャッジ時間 7,229 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 63 ms
71,364 KB
testcase_01 AC 64 ms
71,112 KB
testcase_02 AC 63 ms
71,112 KB
testcase_03 AC 66 ms
71,116 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 64 ms
71,112 KB
testcase_07 AC 65 ms
71,112 KB
testcase_08 AC 67 ms
71,264 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 86 ms
76,464 KB
testcase_14 AC 118 ms
80,124 KB
testcase_15 AC 168 ms
83,712 KB
testcase_16 AC 166 ms
83,608 KB
testcase_17 AC 122 ms
80,056 KB
testcase_18 AC 102 ms
76,472 KB
testcase_19 AC 167 ms
83,412 KB
testcase_20 AC 165 ms
83,060 KB
testcase_21 AC 134 ms
80,856 KB
testcase_22 AC 156 ms
82,424 KB
testcase_23 AC 86 ms
76,484 KB
testcase_24 AC 75 ms
76,252 KB
testcase_25 AC 127 ms
80,636 KB
testcase_26 AC 173 ms
84,008 KB
testcase_27 AC 154 ms
82,776 KB
testcase_28 AC 189 ms
84,852 KB
testcase_29 AC 138 ms
81,152 KB
testcase_30 AC 129 ms
80,900 KB
testcase_31 AC 173 ms
84,016 KB
testcase_32 AC 145 ms
81,668 KB
testcase_33 AC 281 ms
92,600 KB
testcase_34 AC 295 ms
92,360 KB
testcase_35 AC 284 ms
92,452 KB
testcase_36 AC 291 ms
92,396 KB
testcase_37 AC 290 ms
92,432 KB
testcase_38 AC 295 ms
92,156 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# writer解
s = input()
d = int(input())
mod = 10**9+7
digit_sum = 0
blind_count = 0
for i in s:
  if i == "?":
    blind_count += 1
  else:
    digit_sum += int(i)
digit_sum = ((digit_sum-1) % 9)+1

dp = [10*[0]for _ in range(blind_count+1)]
dp[0][0] = 1
for i in range(blind_count):
  for j in range(10):
    for k in range(10):
      jk = j+k
      if jk > 9:
        jk -= 9
      dp[i+1][jk] += dp[i][j]
      dp[i+1][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