結果

問題 No.1085 桁和の桁和
ユーザー uni_pythonuni_python
提出日時 2020-06-20 12:52:22
言語 PyPy3
(7.3.13)
結果
WA  
実行時間 -
コード長 1,060 bytes
コンパイル時間 287 ms
コンパイル使用メモリ 87,232 KB
実行使用メモリ 92,432 KB
最終ジャッジ日時 2023-09-30 06:29:50
合計ジャッジ時間 7,418 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
71,340 KB
testcase_01 AC 72 ms
71,256 KB
testcase_02 AC 72 ms
71,400 KB
testcase_03 AC 71 ms
71,192 KB
testcase_04 AC 76 ms
74,996 KB
testcase_05 AC 70 ms
71,280 KB
testcase_06 AC 72 ms
71,288 KB
testcase_07 AC 70 ms
71,256 KB
testcase_08 AC 71 ms
71,344 KB
testcase_09 WA -
testcase_10 AC 72 ms
71,376 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 101 ms
78,920 KB
testcase_14 AC 132 ms
82,412 KB
testcase_15 AC 193 ms
90,404 KB
testcase_16 AC 191 ms
89,956 KB
testcase_17 AC 138 ms
82,988 KB
testcase_18 AC 112 ms
80,032 KB
testcase_19 AC 181 ms
88,776 KB
testcase_20 AC 79 ms
75,984 KB
testcase_21 AC 146 ms
84,004 KB
testcase_22 AC 172 ms
87,592 KB
testcase_23 AC 93 ms
76,584 KB
testcase_24 AC 86 ms
76,316 KB
testcase_25 AC 143 ms
83,440 KB
testcase_26 AC 195 ms
90,280 KB
testcase_27 AC 172 ms
87,588 KB
testcase_28 AC 208 ms
92,196 KB
testcase_29 AC 152 ms
84,964 KB
testcase_30 AC 146 ms
83,860 KB
testcase_31 AC 189 ms
89,752 KB
testcase_32 AC 158 ms
85,592 KB
testcase_33 AC 285 ms
92,332 KB
testcase_34 AC 293 ms
92,292 KB
testcase_35 AC 284 ms
92,116 KB
testcase_36 AC 284 ms
92,108 KB
testcase_37 AC 287 ms
92,432 KB
testcase_38 AC 286 ms
92,244 KB
権限があれば一括ダウンロードができます

ソースコード

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()
    
    
    dp=[[0]*9 for _ in range(N+1)]
    #dp[i][j]はi番目まで見て桁和の桁和がj
    
    dp[0][0]=1
    
    for i in range(N):
        t=T[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