結果

問題 No.1085 桁和の桁和
ユーザー tamatotamato
提出日時 2020-06-25 01:26:52
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 701 bytes
コンパイル時間 324 ms
コンパイル使用メモリ 87,520 KB
実行使用メモリ 92,668 KB
最終ジャッジ日時 2023-09-30 06:32:09
合計ジャッジ時間 7,769 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
71,604 KB
testcase_01 AC 75 ms
71,604 KB
testcase_02 AC 77 ms
71,504 KB
testcase_03 AC 81 ms
71,408 KB
testcase_04 AC 77 ms
71,592 KB
testcase_05 WA -
testcase_06 AC 76 ms
71,680 KB
testcase_07 AC 75 ms
71,596 KB
testcase_08 AC 78 ms
71,400 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 105 ms
78,980 KB
testcase_14 AC 139 ms
82,708 KB
testcase_15 AC 200 ms
90,340 KB
testcase_16 AC 195 ms
89,976 KB
testcase_17 AC 139 ms
83,104 KB
testcase_18 AC 118 ms
80,316 KB
testcase_19 AC 182 ms
88,488 KB
testcase_20 AC 77 ms
71,624 KB
testcase_21 AC 151 ms
84,332 KB
testcase_22 AC 176 ms
87,872 KB
testcase_23 AC 95 ms
76,676 KB
testcase_24 AC 87 ms
76,400 KB
testcase_25 AC 144 ms
83,640 KB
testcase_26 AC 198 ms
90,452 KB
testcase_27 AC 175 ms
88,040 KB
testcase_28 AC 209 ms
92,584 KB
testcase_29 AC 155 ms
85,516 KB
testcase_30 AC 147 ms
84,424 KB
testcase_31 AC 193 ms
89,864 KB
testcase_32 AC 160 ms
85,696 KB
testcase_33 AC 294 ms
92,484 KB
testcase_34 AC 291 ms
92,452 KB
testcase_35 AC 291 ms
92,576 KB
testcase_36 AC 294 ms
92,640 KB
testcase_37 AC 296 ms
92,668 KB
testcase_38 AC 294 ms
92,420 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    T = input().rstrip('\n')
    D = int(input())
    N = len(T)

    if D == 0:
        if "?"*N != T:
            print(0)
        else:
            print(1)
        exit()

    dp = [[0] * 9 for _ in range(N+1)]
    dp[0][0] = 1
    for i in range(N):
        t = T[i]
        if t != "?":
            t = int(t)
            for j in range(9):
                dp[i+1][(j+t)%9] = dp[i][j]
        else:
            for j in range(9):
                for k in range(10):
                    dp[i+1][(j+k)%9] = (dp[i+1][(j+k)%9] + dp[i][j])%mod
    print(dp[-1][D%9])




if __name__ == '__main__':
    main()
0