結果

問題 No.1085 桁和の桁和
ユーザー chineristACchineristAC
提出日時 2020-06-19 21:40:13
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 697 bytes
コンパイル時間 342 ms
コンパイル使用メモリ 87,004 KB
実行使用メモリ 94,720 KB
最終ジャッジ日時 2023-09-30 06:01:51
合計ジャッジ時間 6,592 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 60 ms
71,280 KB
testcase_01 AC 61 ms
71,180 KB
testcase_02 AC 61 ms
71,180 KB
testcase_03 AC 61 ms
71,240 KB
testcase_04 AC 64 ms
75,780 KB
testcase_05 AC 63 ms
71,224 KB
testcase_06 AC 61 ms
71,116 KB
testcase_07 AC 61 ms
71,212 KB
testcase_08 RE -
testcase_09 RE -
testcase_10 AC 60 ms
71,112 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 113 ms
78,624 KB
testcase_14 RE -
testcase_15 RE -
testcase_16 AC 184 ms
89,312 KB
testcase_17 AC 127 ms
82,824 KB
testcase_18 RE -
testcase_19 RE -
testcase_20 AC 61 ms
71,188 KB
testcase_21 AC 136 ms
84,696 KB
testcase_22 AC 164 ms
87,456 KB
testcase_23 AC 85 ms
78,088 KB
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 AC 170 ms
87,272 KB
testcase_28 AC 208 ms
91,548 KB
testcase_29 AC 143 ms
85,008 KB
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
testcase_34 RE -
testcase_35 RE -
testcase_36 RE -
testcase_37 RE -
testcase_38 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

T=input()
D=int(input())
N=len(T)
mod=10**9+7

if D==0:
    for i in range(N):
        if T[i]!="0" and T[i]!="?":
            print(0)
            break
    else:
        print(1)
else:
    dp=[[0 for i in range(9)] for j in range(N)]
    if T[0]=="?":
        for j in range(9):
            dp[0][i]=1
        dp[0][0]=2
    else:
        dp[0][int(T[0])]=1
    for i in range(1,N):
        for j in range(9):
            if T[i]=="?":
                for k in range(10):
                    dp[i][(j+k)%9]+=dp[i-1][j]
                    dp[i][(j+k)%9]%=mod
            else:
                dp[i][(j+int(T[i]))%9]+=dp[i-1][j]
                dp[i][(j+int(T[i]))%9]%=mod
    print(dp[-1][D%9])
0