結果

問題 No.1085 桁和の桁和
ユーザー chineristACchineristAC
提出日時 2020-06-19 21:46:37
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 906 bytes
コンパイル時間 250 ms
コンパイル使用メモリ 87,000 KB
実行使用メモリ 92,044 KB
最終ジャッジ日時 2023-09-30 06:03:08
合計ジャッジ時間 6,925 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 68 ms
71,424 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 72 ms
75,480 KB
testcase_05 AC 64 ms
71,320 KB
testcase_06 AC 64 ms
71,248 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 59 ms
71,328 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 62 ms
71,256 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
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 #

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
    print(dp[-1][D%9])
    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