結果

問題 No.1085 桁和の桁和
ユーザー chineristACchineristAC
提出日時 2020-06-19 21:49:47
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 318 ms / 2,000 ms
コード長 884 bytes
コンパイル時間 1,009 ms
コンパイル使用メモリ 86,928 KB
実行使用メモリ 91,908 KB
最終ジャッジ日時 2023-08-06 14:27:48
合計ジャッジ時間 8,238 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,172 KB
testcase_01 AC 69 ms
71,224 KB
testcase_02 AC 70 ms
71,384 KB
testcase_03 AC 72 ms
71,268 KB
testcase_04 AC 77 ms
75,340 KB
testcase_05 AC 72 ms
71,500 KB
testcase_06 AC 70 ms
71,224 KB
testcase_07 AC 69 ms
71,368 KB
testcase_08 AC 70 ms
71,112 KB
testcase_09 AC 71 ms
71,064 KB
testcase_10 AC 73 ms
71,076 KB
testcase_11 AC 71 ms
71,312 KB
testcase_12 AC 84 ms
76,464 KB
testcase_13 AC 108 ms
78,832 KB
testcase_14 AC 144 ms
82,668 KB
testcase_15 AC 217 ms
89,796 KB
testcase_16 AC 217 ms
89,428 KB
testcase_17 AC 152 ms
82,972 KB
testcase_18 AC 119 ms
80,064 KB
testcase_19 AC 207 ms
88,412 KB
testcase_20 AC 72 ms
71,092 KB
testcase_21 AC 163 ms
84,580 KB
testcase_22 AC 198 ms
87,436 KB
testcase_23 AC 102 ms
78,032 KB
testcase_24 AC 88 ms
76,632 KB
testcase_25 AC 158 ms
83,680 KB
testcase_26 AC 225 ms
90,040 KB
testcase_27 AC 196 ms
87,624 KB
testcase_28 AC 243 ms
91,852 KB
testcase_29 AC 166 ms
84,972 KB
testcase_30 AC 162 ms
84,640 KB
testcase_31 AC 216 ms
89,496 KB
testcase_32 AC 182 ms
85,700 KB
testcase_33 AC 316 ms
91,808 KB
testcase_34 AC 318 ms
91,768 KB
testcase_35 AC 317 ms
91,908 KB
testcase_36 AC 317 ms
91,872 KB
testcase_37 AC 317 ms
91,872 KB
testcase_38 AC 317 ms
91,892 KB
権限があれば一括ダウンロードができます

ソースコード

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(10):
            dp[0][j%9]+=1
    else:
        dp[0][int(T[0])%9]=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
    ans=dp[-1][D%9]
    if D!=9:
        print(ans)
    else:
        for i in range(N):
            if T[i]!="0" and T[i]!="?":
                print(ans)
                break
        else:
            print((ans-1)%mod)
0