結果

問題 No.1085 桁和の桁和
ユーザー tyawanmusityawanmusi
提出日時 2020-05-20 01:03:30
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 298 ms / 2,000 ms
コード長 728 bytes
コンパイル時間 179 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 91,648 KB
最終ジャッジ日時 2024-04-24 10:00:25
合計ジャッジ時間 6,486 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
51,840 KB
testcase_01 AC 39 ms
51,968 KB
testcase_02 AC 41 ms
51,840 KB
testcase_03 AC 43 ms
51,840 KB
testcase_04 AC 281 ms
91,136 KB
testcase_05 AC 42 ms
51,840 KB
testcase_06 AC 41 ms
51,968 KB
testcase_07 AC 42 ms
51,968 KB
testcase_08 AC 44 ms
51,584 KB
testcase_09 AC 41 ms
52,096 KB
testcase_10 AC 42 ms
51,712 KB
testcase_11 AC 41 ms
51,712 KB
testcase_12 AC 50 ms
60,032 KB
testcase_13 AC 77 ms
68,480 KB
testcase_14 AC 114 ms
78,848 KB
testcase_15 AC 171 ms
83,072 KB
testcase_16 AC 169 ms
82,688 KB
testcase_17 AC 117 ms
79,104 KB
testcase_18 AC 87 ms
72,576 KB
testcase_19 AC 157 ms
82,176 KB
testcase_20 AC 161 ms
82,304 KB
testcase_21 AC 130 ms
79,872 KB
testcase_22 AC 153 ms
81,664 KB
testcase_23 AC 70 ms
66,560 KB
testcase_24 AC 56 ms
61,696 KB
testcase_25 AC 122 ms
79,488 KB
testcase_26 AC 171 ms
82,816 KB
testcase_27 AC 153 ms
81,664 KB
testcase_28 AC 189 ms
83,968 KB
testcase_29 AC 132 ms
80,512 KB
testcase_30 AC 125 ms
79,872 KB
testcase_31 AC 168 ms
82,944 KB
testcase_32 AC 137 ms
80,896 KB
testcase_33 AC 294 ms
91,520 KB
testcase_34 AC 297 ms
91,136 KB
testcase_35 AC 296 ms
91,136 KB
testcase_36 AC 298 ms
91,392 KB
testcase_37 AC 295 ms
91,520 KB
testcase_38 AC 295 ms
91,648 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)
        if digit_sum > 9:
            digit_sum -= 9

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