結果

問題 No.1085 桁和の桁和
ユーザー titiatitia
提出日時 2020-06-19 22:55:32
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 516 bytes
コンパイル時間 331 ms
コンパイル使用メモリ 86,936 KB
実行使用メモリ 77,740 KB
最終ジャッジ日時 2023-09-30 06:24:12
合計ジャッジ時間 5,966 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 63 ms
71,188 KB
testcase_01 AC 63 ms
71,192 KB
testcase_02 AC 66 ms
71,384 KB
testcase_03 AC 64 ms
71,208 KB
testcase_04 AC 133 ms
77,740 KB
testcase_05 AC 62 ms
71,100 KB
testcase_06 AC 63 ms
71,264 KB
testcase_07 AC 65 ms
71,108 KB
testcase_08 AC 63 ms
71,276 KB
testcase_09 WA -
testcase_10 AC 63 ms
71,412 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 82 ms
76,612 KB
testcase_14 AC 87 ms
77,048 KB
testcase_15 AC 99 ms
77,124 KB
testcase_16 AC 96 ms
77,044 KB
testcase_17 AC 90 ms
77,044 KB
testcase_18 AC 79 ms
76,584 KB
testcase_19 AC 101 ms
77,100 KB
testcase_20 AC 117 ms
77,680 KB
testcase_21 AC 107 ms
77,028 KB
testcase_22 AC 110 ms
77,100 KB
testcase_23 AC 88 ms
76,568 KB
testcase_24 AC 83 ms
76,456 KB
testcase_25 AC 105 ms
77,100 KB
testcase_26 AC 117 ms
77,132 KB
testcase_27 AC 110 ms
77,256 KB
testcase_28 AC 121 ms
77,012 KB
testcase_29 AC 107 ms
77,124 KB
testcase_30 AC 103 ms
77,080 KB
testcase_31 AC 116 ms
77,348 KB
testcase_32 AC 112 ms
77,064 KB
testcase_33 AC 150 ms
77,108 KB
testcase_34 AC 135 ms
77,208 KB
testcase_35 AC 130 ms
77,072 KB
testcase_36 AC 131 ms
77,068 KB
testcase_37 AC 130 ms
77,132 KB
testcase_38 AC 128 ms
77,100 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[i]+=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)
    
else:
    print(DP[D%9]%mod)
0