結果

問題 No.1085 桁和の桁和
ユーザー tanon710tanon710
提出日時 2020-06-19 23:05:22
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 714 bytes
コンパイル時間 306 ms
コンパイル使用メモリ 86,840 KB
実行使用メモリ 843,100 KB
最終ジャッジ日時 2023-09-30 06:26:46
合計ジャッジ時間 7,432 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 64 ms
71,360 KB
testcase_01 AC 68 ms
71,372 KB
testcase_02 AC 67 ms
71,376 KB
testcase_03 AC 66 ms
71,100 KB
testcase_04 AC 70 ms
75,640 KB
testcase_05 AC 65 ms
71,192 KB
testcase_06 AC 68 ms
71,248 KB
testcase_07 AC 66 ms
71,088 KB
testcase_08 AC 65 ms
71,192 KB
testcase_09 AC 65 ms
71,292 KB
testcase_10 AC 68 ms
71,252 KB
testcase_11 AC 68 ms
71,388 KB
testcase_12 AC 78 ms
76,320 KB
testcase_13 WA -
testcase_14 TLE -
testcase_15 MLE -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

mod=10**9+7
t=input()
d=int(input())
tmp=0
cnt=0
for c in t:
    if c=='?':
        cnt+=1
    else:
        tmp+=int(c)
if d!=0:
    if tmp!=0 and tmp%9==0:
        tmp=9
    dp=[[0]*10 for _ in range(cnt+1)]
    dp[0][0]=1
    for i in range(1,cnt+1):
        for j in range(10):
            for k in range(10):
                if j+k==0:
                    dp[i][0]+=dp[i-1][j]
                elif j+k==9 or j+k==18:
                    dp[i][9]+=dp[i-1][j]
                else:
                    dp[i][(j+k)%9]+=dp[i-1][j]
    ans=0
    for i in range(10):
        if tmp+i==d or tmp+i==d+9:
            ans+=dp[-1][i]
    print(ans%mod)
if d==0:
    if tmp!=0:
        print(0)
    else:
        print(1)
0