結果

問題 No.1085 桁和の桁和
ユーザー shotoyooshotoyoo
提出日時 2021-06-19 00:14:23
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 138 ms / 2,000 ms
コード長 758 bytes
コンパイル時間 295 ms
コンパイル使用メモリ 87,012 KB
実行使用メモリ 78,368 KB
最終ジャッジ日時 2023-09-05 00:31:05
合計ジャッジ時間 7,521 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,392 KB
testcase_01 AC 69 ms
71,436 KB
testcase_02 AC 74 ms
71,472 KB
testcase_03 AC 72 ms
71,124 KB
testcase_04 AC 124 ms
77,516 KB
testcase_05 AC 75 ms
71,392 KB
testcase_06 AC 70 ms
71,260 KB
testcase_07 AC 76 ms
71,436 KB
testcase_08 AC 71 ms
71,512 KB
testcase_09 AC 71 ms
71,376 KB
testcase_10 AC 71 ms
71,460 KB
testcase_11 AC 72 ms
71,452 KB
testcase_12 AC 73 ms
71,128 KB
testcase_13 AC 94 ms
77,536 KB
testcase_14 AC 108 ms
77,440 KB
testcase_15 AC 110 ms
77,424 KB
testcase_16 AC 110 ms
77,524 KB
testcase_17 AC 107 ms
77,444 KB
testcase_18 AC 95 ms
77,432 KB
testcase_19 AC 120 ms
77,840 KB
testcase_20 AC 138 ms
77,964 KB
testcase_21 AC 99 ms
77,488 KB
testcase_22 AC 116 ms
77,944 KB
testcase_23 AC 89 ms
77,144 KB
testcase_24 AC 82 ms
76,680 KB
testcase_25 AC 109 ms
78,068 KB
testcase_26 AC 117 ms
77,572 KB
testcase_27 AC 107 ms
77,520 KB
testcase_28 AC 114 ms
77,544 KB
testcase_29 AC 103 ms
77,468 KB
testcase_30 AC 113 ms
77,848 KB
testcase_31 AC 126 ms
78,368 KB
testcase_32 AC 108 ms
77,344 KB
testcase_33 AC 128 ms
77,612 KB
testcase_34 AC 128 ms
77,468 KB
testcase_35 AC 129 ms
77,536 KB
testcase_36 AC 128 ms
77,476 KB
testcase_37 AC 132 ms
77,524 KB
testcase_38 AC 123 ms
77,592 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda : sys.stdin.readline().rstrip()

sys.setrecursionlimit(2*10**5+10)
write = lambda x: sys.stdout.write(x+"\n")
debug = lambda x: sys.stderr.write(x+"\n")
writef = lambda x: print("{:.12f}".format(x))


t = input()[::-1]
d = int(input())
dp = [0]*9
dp[0] = 1
M = 10**9+7
for c in t:
    ndp = [0]*9
    if c!="?":
        v = int(c)
        for i in range(9):
            ndp[(i+v)%9] += dp[i]
    else:
        val = sum(dp)%M
        ndp = [val+dp[i] for i in range(9)]
        
    dp = ndp
if d==0:
    if all(((c=="0" or c=="?") for c in t)):
        ans = 1
    else:
        ans = 0
elif d==9:
    if all(((c=="0" or c=="?") for c in t)):
        ans = dp[0] - 1
    else:
        ans = dp[0]
else:
    ans = dp[d]
print(ans%M)
0