結果

問題 No.1085 桁和の桁和
ユーザー uni_pythonuni_python
提出日時 2020-06-20 13:08:53
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,321 bytes
コンパイル時間 235 ms
コンパイル使用メモリ 86,948 KB
実行使用メモリ 96,400 KB
最終ジャッジ日時 2023-09-30 06:29:58
合計ジャッジ時間 6,963 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,176 KB
testcase_01 AC 65 ms
71,376 KB
testcase_02 AC 64 ms
71,124 KB
testcase_03 AC 65 ms
71,084 KB
testcase_04 AC 69 ms
75,356 KB
testcase_05 AC 72 ms
71,332 KB
testcase_06 AC 64 ms
71,352 KB
testcase_07 AC 65 ms
71,236 KB
testcase_08 AC 66 ms
71,364 KB
testcase_09 AC 65 ms
71,380 KB
testcase_10 AC 62 ms
71,412 KB
testcase_11 AC 63 ms
71,192 KB
testcase_12 WA -
testcase_13 RE -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 189 ms
93,872 KB
testcase_17 AC 127 ms
85,556 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 72 ms
76,232 KB
testcase_21 AC 137 ms
87,776 KB
testcase_22 AC 170 ms
92,536 KB
testcase_23 AC 90 ms
78,156 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 172 ms
93,148 KB
testcase_28 AC 215 ms
95,312 KB
testcase_29 AC 147 ms
88,764 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    T=input()
    D=I()
    N=len(T)
    
    if D==0:
        S=0
        cnt=0
        for i in range(N):
            if T[i]=="?":
                cnt+=1
            else:
                S+=int(T[i])
        if S==0:
            print(1)
        else:
            print(0)
        exit()
        
    T2=[]
    for i in range(N):
        if T[i]!="0":
            T2.append(T[i])
            
    if T2==[]:
        print(0)
        exit()
    
    N=len(T2)
    dp=[[0]*9 for _ in range(N+1)]
    #dp[i][j]はi番目まで見て桁和の桁和がj

    
    t=T2[0]
    if t=="?":
        for j in range(9):
            dp[1][j]=1
    else:
        dp[1][int(t)]=1
    
    for i in range(1,N):
        t=T2[i]
        if t=="?":
            for j in range(9):
                dp[i][j]=dp[i][j]%mod
                for k in range(10):#?をkにする
                    dp[i+1][(j+k)%9]+=dp[i][j]
                    
                
        else:
            t=int(t)
            for j in range(9):
                dp[i][j]=dp[i][j]%mod
                dp[i+1][(j+t)%9]=dp[i][j]
                
    print(dp[-1][D%9]%mod)
    
            
            



main()
0