結果

問題 No.1085 桁和の桁和
ユーザー chineristACchineristAC
提出日時 2020-06-19 21:49:47
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 263 ms / 2,000 ms
コード長 884 bytes
コンパイル時間 165 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 90,880 KB
最終ジャッジ日時 2024-04-24 10:01:27
合計ジャッジ時間 5,773 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
51,968 KB
testcase_01 AC 37 ms
51,584 KB
testcase_02 AC 44 ms
51,840 KB
testcase_03 AC 39 ms
52,480 KB
testcase_04 AC 39 ms
58,496 KB
testcase_05 AC 35 ms
51,968 KB
testcase_06 AC 35 ms
52,224 KB
testcase_07 AC 34 ms
52,096 KB
testcase_08 AC 34 ms
52,224 KB
testcase_09 AC 34 ms
51,968 KB
testcase_10 AC 34 ms
51,712 KB
testcase_11 AC 35 ms
52,352 KB
testcase_12 AC 47 ms
60,416 KB
testcase_13 AC 86 ms
77,696 KB
testcase_14 AC 115 ms
81,536 KB
testcase_15 AC 174 ms
88,832 KB
testcase_16 AC 176 ms
88,320 KB
testcase_17 AC 114 ms
82,304 KB
testcase_18 AC 89 ms
78,848 KB
testcase_19 AC 160 ms
87,296 KB
testcase_20 AC 35 ms
52,352 KB
testcase_21 AC 131 ms
83,072 KB
testcase_22 AC 161 ms
86,400 KB
testcase_23 AC 68 ms
72,960 KB
testcase_24 AC 56 ms
65,280 KB
testcase_25 AC 128 ms
82,688 KB
testcase_26 AC 192 ms
88,960 KB
testcase_27 AC 154 ms
86,528 KB
testcase_28 AC 199 ms
90,624 KB
testcase_29 AC 137 ms
83,840 KB
testcase_30 AC 131 ms
83,328 KB
testcase_31 AC 177 ms
88,704 KB
testcase_32 AC 139 ms
84,352 KB
testcase_33 AC 260 ms
90,752 KB
testcase_34 AC 258 ms
90,880 KB
testcase_35 AC 260 ms
90,752 KB
testcase_36 AC 258 ms
90,752 KB
testcase_37 AC 262 ms
90,624 KB
testcase_38 AC 263 ms
90,880 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