結果

問題 No.1085 桁和の桁和
ユーザー 👑 rin204rin204
提出日時 2022-07-14 13:31:23
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 661 bytes
コンパイル時間 274 ms
コンパイル使用メモリ 87,188 KB
実行使用メモリ 77,636 KB
最終ジャッジ日時 2023-09-08 03:34:15
合計ジャッジ時間 6,155 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
71,620 KB
testcase_01 AC 70 ms
71,476 KB
testcase_02 AC 70 ms
71,120 KB
testcase_03 AC 72 ms
71,552 KB
testcase_04 AC 82 ms
75,536 KB
testcase_05 AC 71 ms
71,264 KB
testcase_06 AC 73 ms
71,476 KB
testcase_07 AC 71 ms
71,356 KB
testcase_08 AC 72 ms
71,384 KB
testcase_09 WA -
testcase_10 AC 71 ms
71,440 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 91 ms
76,940 KB
testcase_14 AC 114 ms
77,360 KB
testcase_15 AC 152 ms
77,240 KB
testcase_16 AC 151 ms
77,088 KB
testcase_17 AC 116 ms
77,304 KB
testcase_18 AC 99 ms
77,244 KB
testcase_19 AC 143 ms
77,248 KB
testcase_20 AC 69 ms
71,280 KB
testcase_21 AC 125 ms
77,220 KB
testcase_22 AC 142 ms
77,504 KB
testcase_23 AC 91 ms
76,856 KB
testcase_24 AC 85 ms
76,680 KB
testcase_25 AC 119 ms
77,300 KB
testcase_26 AC 158 ms
77,388 KB
testcase_27 AC 140 ms
77,060 KB
testcase_28 AC 163 ms
77,372 KB
testcase_29 AC 129 ms
77,456 KB
testcase_30 AC 125 ms
77,252 KB
testcase_31 AC 156 ms
77,444 KB
testcase_32 AC 135 ms
77,080 KB
testcase_33 AC 153 ms
77,280 KB
testcase_34 AC 150 ms
77,144 KB
testcase_35 AC 151 ms
77,492 KB
testcase_36 AC 151 ms
77,636 KB
testcase_37 AC 151 ms
77,332 KB
testcase_38 AC 150 ms
77,544 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 == 9 and all(t in "0?" for t in T):
        dp[0] -= 1
        dp[0] %= MOD
    print(dp[d])


0