結果

問題 No.1085 桁和の桁和
ユーザー titiatitia
提出日時 2020-06-19 23:02:40
言語 PyPy3
(7.3.15)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 551 bytes
コンパイル時間 724 ms
コンパイル使用メモリ 86,928 KB
実行使用メモリ 77,712 KB
最終ジャッジ日時 2023-09-30 06:25:57
合計ジャッジ時間 6,049 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
71,256 KB
testcase_01 AC 76 ms
71,192 KB
testcase_02 AC 78 ms
71,344 KB
testcase_03 AC 74 ms
71,296 KB
testcase_04 AC 148 ms
77,712 KB
testcase_05 AC 75 ms
71,344 KB
testcase_06 AC 75 ms
71,156 KB
testcase_07 AC 75 ms
71,148 KB
testcase_08 AC 76 ms
71,292 KB
testcase_09 AC 77 ms
71,324 KB
testcase_10 AC 76 ms
71,092 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 92 ms
76,612 KB
testcase_14 AC 104 ms
77,044 KB
testcase_15 AC 119 ms
77,192 KB
testcase_16 AC 117 ms
77,148 KB
testcase_17 AC 103 ms
77,044 KB
testcase_18 AC 96 ms
76,508 KB
testcase_19 AC 116 ms
76,996 KB
testcase_20 AC 118 ms
77,596 KB
testcase_21 AC 104 ms
77,096 KB
testcase_22 AC 111 ms
77,216 KB
testcase_23 AC 91 ms
76,460 KB
testcase_24 AC 85 ms
76,348 KB
testcase_25 AC 105 ms
76,996 KB
testcase_26 AC 119 ms
77,144 KB
testcase_27 AC 113 ms
77,012 KB
testcase_28 AC 123 ms
76,964 KB
testcase_29 AC 105 ms
77,052 KB
testcase_30 AC 107 ms
76,808 KB
testcase_31 AC 118 ms
77,108 KB
testcase_32 AC 107 ms
77,160 KB
testcase_33 AC 147 ms
77,108 KB
testcase_34 AC 147 ms
77,104 KB
testcase_35 AC 147 ms
77,236 KB
testcase_36 AC 150 ms
76,856 KB
testcase_37 AC 147 ms
76,860 KB
testcase_38 AC 151 ms
77,260 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 T=="?" and D==9:
    print(1)
    
else:
    print(DP[D%9]%mod)
0