結果

問題 No.1085 桁和の桁和
ユーザー vwxyzvwxyz
提出日時 2021-08-12 01:16:23
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,602 bytes
コンパイル時間 253 ms
コンパイル使用メモリ 81,688 KB
実行使用メモリ 89,724 KB
最終ジャッジ日時 2023-10-26 03:14:09
合計ジャッジ時間 8,258 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 159 ms
88,932 KB
testcase_01 AC 159 ms
88,924 KB
testcase_02 AC 148 ms
88,928 KB
testcase_03 AC 147 ms
88,924 KB
testcase_04 AC 160 ms
89,388 KB
testcase_05 AC 149 ms
88,920 KB
testcase_06 AC 148 ms
88,916 KB
testcase_07 AC 145 ms
88,932 KB
testcase_08 AC 145 ms
88,928 KB
testcase_09 WA -
testcase_10 AC 148 ms
88,932 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 154 ms
89,716 KB
testcase_14 AC 153 ms
89,724 KB
testcase_15 AC 153 ms
89,716 KB
testcase_16 AC 154 ms
89,712 KB
testcase_17 AC 151 ms
89,716 KB
testcase_18 AC 153 ms
89,720 KB
testcase_19 AC 154 ms
89,724 KB
testcase_20 AC 148 ms
88,928 KB
testcase_21 AC 157 ms
89,716 KB
testcase_22 AC 155 ms
89,668 KB
testcase_23 AC 153 ms
89,712 KB
testcase_24 AC 150 ms
89,324 KB
testcase_25 AC 154 ms
89,720 KB
testcase_26 AC 154 ms
89,720 KB
testcase_27 AC 161 ms
89,712 KB
testcase_28 AC 154 ms
89,720 KB
testcase_29 AC 155 ms
89,720 KB
testcase_30 AC 152 ms
89,716 KB
testcase_31 AC 155 ms
89,704 KB
testcase_32 AC 153 ms
89,712 KB
testcase_33 AC 155 ms
89,716 KB
testcase_34 AC 154 ms
89,716 KB
testcase_35 AC 152 ms
89,712 KB
testcase_36 AC 153 ms
89,720 KB
testcase_37 AC 152 ms
89,716 KB
testcase_38 AC 153 ms
89,720 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

def Power(x,n,f,e):
    if n==0:
        return e
    s=e
    double=x
    while n>=2:
        if n&1:
            s=f(s,double)
        double=f(double,double)
        n>>=1
    s=f(s,double)
    return s

S=readline().rstrip()
D=int(readline())
if D==0:
    for s in S:
        if not s in "0?":
            ans=0
            break
    else:
        ans=1
else:
    cnt=0
    su=D
    mod=10**9+7
    for s in S:
        if s=="?":
            cnt+=1
        else:
            su-=int(s)
    su%=9
    def f(poly0,poly1):
        poly=[0]*9
        for i in range(9):
            for j in range(9):
                poly[(i+j)%9]+=poly0[i]*poly1[j]
                poly[(i+j)%9]%=mod
        return poly
    e=[0]*9
    e[0]=1
    x=[1]*9
    x[0]=2
    ans=Power(x,cnt,f,e)[su]
    if D==0:
        for s in S:
            if not s in "0?":
                break
        else:
            ans-=1
            ans%=mod
print(ans)
0