結果

問題 No.1085 桁和の桁和
コンテスト
ユーザー tanon710
提出日時 2020-06-19 23:05:22
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
WA  
実行時間 -
コード長 714 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 196 ms
コンパイル使用メモリ 84,720 KB
実行使用メモリ 1,337,416 KB
最終ジャッジ日時 2026-04-03 11:47:58
合計ジャッジ時間 6,077 ms
ジャッジサーバーID
(参考情報)
judge4_1 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 9 WA * 1 MLE * 3 -- * 22
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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