結果

問題 No.1085 桁和の桁和
ユーザー 👑 rin204rin204
提出日時 2022-07-14 13:32:04
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 164 ms / 2,000 ms
コード長 661 bytes
コンパイル時間 276 ms
コンパイル使用メモリ 87,216 KB
実行使用メモリ 77,500 KB
最終ジャッジ日時 2023-09-08 03:34:47
合計ジャッジ時間 6,140 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,328 KB
testcase_01 AC 71 ms
71,308 KB
testcase_02 AC 70 ms
71,532 KB
testcase_03 AC 71 ms
71,544 KB
testcase_04 AC 72 ms
75,436 KB
testcase_05 AC 67 ms
71,280 KB
testcase_06 AC 69 ms
71,052 KB
testcase_07 AC 69 ms
71,124 KB
testcase_08 AC 68 ms
71,432 KB
testcase_09 AC 67 ms
71,440 KB
testcase_10 AC 67 ms
71,352 KB
testcase_11 AC 67 ms
71,432 KB
testcase_12 AC 74 ms
76,384 KB
testcase_13 AC 90 ms
76,672 KB
testcase_14 AC 110 ms
77,164 KB
testcase_15 AC 147 ms
77,460 KB
testcase_16 AC 145 ms
77,188 KB
testcase_17 AC 114 ms
77,236 KB
testcase_18 AC 100 ms
77,104 KB
testcase_19 AC 143 ms
77,212 KB
testcase_20 AC 71 ms
71,332 KB
testcase_21 AC 122 ms
77,136 KB
testcase_22 AC 139 ms
77,016 KB
testcase_23 AC 88 ms
76,648 KB
testcase_24 AC 83 ms
76,652 KB
testcase_25 AC 116 ms
77,436 KB
testcase_26 AC 154 ms
77,244 KB
testcase_27 AC 141 ms
77,244 KB
testcase_28 AC 164 ms
77,248 KB
testcase_29 AC 127 ms
77,424 KB
testcase_30 AC 124 ms
77,332 KB
testcase_31 AC 156 ms
77,272 KB
testcase_32 AC 133 ms
77,148 KB
testcase_33 AC 151 ms
77,440 KB
testcase_34 AC 149 ms
77,208 KB
testcase_35 AC 149 ms
77,336 KB
testcase_36 AC 150 ms
77,500 KB
testcase_37 AC 150 ms
77,400 KB
testcase_38 AC 152 ms
77,268 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD = 10 ** 9 + 7

T = input()
d = int(input())
if d == 0:
    ans = 1
    if all(t in "0?" for t in T):
        print(1)
    else:
        print(0)
else:
    if d == 9:
        d = 0
    dp = [0] * 9
    dp[0] = 1
    for t in T:
        ndp = [0] * 9
        if t == "?":
            for i in range(9):
                for j in range(10):
                    ndp[(i + j) % 9] += dp[i]
        else:
            t = int(t)
            for i in range(9):
                ndp[(i + t) % 9] += dp[i]
        for i in range(9):
            dp[i] = ndp[i] % MOD
    if d == 0 and all(t in "0?" for t in T):
        dp[0] -= 1
        dp[0] %= MOD
    print(dp[d])


0