結果

問題 No.1085 桁和の桁和
ユーザー titiatitia
提出日時 2020-06-20 01:59:42
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 120 ms / 2,000 ms
コード長 576 bytes
コンパイル時間 271 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 78,464 KB
最終ジャッジ日時 2024-04-24 10:08:27
合計ジャッジ時間 3,939 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
51,840 KB
testcase_01 AC 39 ms
52,096 KB
testcase_02 AC 41 ms
52,352 KB
testcase_03 AC 44 ms
51,968 KB
testcase_04 AC 120 ms
77,184 KB
testcase_05 AC 37 ms
51,968 KB
testcase_06 AC 37 ms
51,968 KB
testcase_07 AC 37 ms
52,352 KB
testcase_08 AC 37 ms
51,840 KB
testcase_09 AC 36 ms
51,968 KB
testcase_10 AC 37 ms
51,712 KB
testcase_11 AC 39 ms
51,840 KB
testcase_12 AC 44 ms
58,496 KB
testcase_13 AC 56 ms
66,560 KB
testcase_14 AC 72 ms
76,288 KB
testcase_15 AC 88 ms
75,904 KB
testcase_16 AC 87 ms
75,904 KB
testcase_17 AC 77 ms
76,288 KB
testcase_18 AC 65 ms
70,272 KB
testcase_19 AC 84 ms
76,416 KB
testcase_20 AC 85 ms
76,800 KB
testcase_21 AC 76 ms
76,032 KB
testcase_22 AC 81 ms
76,160 KB
testcase_23 AC 55 ms
65,024 KB
testcase_24 AC 46 ms
61,440 KB
testcase_25 AC 75 ms
76,032 KB
testcase_26 AC 97 ms
78,464 KB
testcase_27 AC 82 ms
76,160 KB
testcase_28 AC 94 ms
75,904 KB
testcase_29 AC 82 ms
76,160 KB
testcase_30 AC 82 ms
76,160 KB
testcase_31 AC 89 ms
76,160 KB
testcase_32 AC 81 ms
75,904 KB
testcase_33 AC 115 ms
76,032 KB
testcase_34 AC 115 ms
75,904 KB
testcase_35 AC 115 ms
76,416 KB
testcase_36 AC 115 ms
76,416 KB
testcase_37 AC 116 ms
75,904 KB
testcase_38 AC 115 ms
76,416 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

T=input().strip()
D=int(input())
mod=10**9+7

Q=0
W=0
for t in T:
    if t=="?":
        Q+=1
    else:
        W+=int(t)

DP=[0]*9
DP[W%9]=1

for t in range(Q):
    NDP=[0]*9
    for i in range(9):
        for j in range(9):
            if i==j:
                NDP[j]+=DP[i]*2
            else:
                NDP[j]+=DP[i]

            NDP[j]%=mod
    DP=NDP

if D==0:
    if set(T)<={"0","?"}:
        print(1)
    else:
        print(0)
elif D==9 and set(T)<={"0","?"}:
    print((DP[D%9]-1)%mod)
    
else:
    print(DP[D%9]%mod)
0