結果

問題 No.1085 桁和の桁和
ユーザー vwxyzvwxyz
提出日時 2021-08-11 23:57:30
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,238 bytes
コンパイル時間 840 ms
コンパイル使用メモリ 81,616 KB
実行使用メモリ 90,084 KB
最終ジャッジ日時 2023-10-26 01:58:36
合計ジャッジ時間 11,233 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 151 ms
88,884 KB
testcase_01 AC 153 ms
88,880 KB
testcase_02 AC 152 ms
88,856 KB
testcase_03 AC 166 ms
89,760 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 149 ms
88,880 KB
testcase_07 AC 151 ms
88,884 KB
testcase_08 WA -
testcase_09 AC 150 ms
88,884 KB
testcase_10 WA -
testcase_11 AC 152 ms
89,692 KB
testcase_12 AC 157 ms
89,780 KB
testcase_13 AC 185 ms
89,800 KB
testcase_14 AC 241 ms
89,876 KB
testcase_15 AC 329 ms
89,908 KB
testcase_16 AC 329 ms
89,908 KB
testcase_17 AC 243 ms
89,880 KB
testcase_18 AC 208 ms
89,804 KB
testcase_19 AC 315 ms
89,880 KB
testcase_20 AC 149 ms
88,880 KB
testcase_21 AC 259 ms
89,880 KB
testcase_22 AC 308 ms
89,880 KB
testcase_23 AC 171 ms
89,796 KB
testcase_24 AC 163 ms
89,804 KB
testcase_25 AC 250 ms
89,880 KB
testcase_26 AC 343 ms
89,912 KB
testcase_27 AC 300 ms
89,880 KB
testcase_28 AC 363 ms
89,908 KB
testcase_29 AC 267 ms
89,880 KB
testcase_30 AC 264 ms
89,880 KB
testcase_31 AC 339 ms
89,908 KB
testcase_32 AC 278 ms
89,880 KB
testcase_33 AC 271 ms
89,972 KB
testcase_34 AC 268 ms
90,084 KB
testcase_35 AC 268 ms
89,972 KB
testcase_36 AC 269 ms
89,976 KB
testcase_37 AC 268 ms
89,972 KB
testcase_38 AC 270 ms
89,972 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import bisect
import copy
import decimal
import fractions
import functools
import heapq
import itertools
import math
import random
import sys
from collections import Counter,deque,defaultdict
from functools import lru_cache,reduce
from heapq import heappush,heappop,heapify,heappushpop,_heappop_max,_heapify_max
def _heappush_max(heap,item):
    heap.append(item)
    heapq._siftdown_max(heap, 0, len(heap)-1)
def _heappushpop_max(heap, item):
    if heap and item < heap[0]:
        item, heap[0] = heap[0], item
        heapq._siftup_max(heap, 0)
    return item
from math import gcd as GCD
read=sys.stdin.read
readline=sys.stdin.readline
readlines=sys.stdin.readlines

S=readline().rstrip()
D=int(readline())
if D==0:
    for s in S:
        if not s in "0?":
            ans=0
            break
    else:
        ans=0
else:
    D%=9
    mod=10**9+7
    dp=[0]*9
    dp[0]=1
    for s in S[::-1]:
        prev=dp
        dp=[0]*9
        for i in range(9):
            for j in range(10):
                if s=="?" or int(s)==j:
                    dp[(i+j)%9]+=prev[i]
                    dp[(i+j)%9]%=mod

    ans=dp[D]
    for s in S:
        if not s in "0?":
            break
    else:
        ans-=1
        ans%=mod
print(ans)
0