結果
問題 | No.1085 桁和の桁和 |
ユーザー |
![]() |
提出日時 | 2021-08-12 01:18:29 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 69 ms / 2,000 ms |
コード長 | 1,611 bytes |
コンパイル時間 | 301 ms |
コンパイル使用メモリ | 12,800 KB |
実行使用メモリ | 12,288 KB |
最終ジャッジ日時 | 2024-09-25 11:13:17 |
合計ジャッジ時間 | 3,489 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 35 |
ソースコード
import bisectimport copyimport decimalimport fractionsimport functoolsimport heapqimport itertoolsimport mathimport randomimport sysfrom collections import Counter,deque,defaultdictfrom functools import lru_cache,reducefrom heapq import heappush,heappop,heapify,heappushpop,_heappop_max,_heapify_maxdef _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], itemheapq._siftup_max(heap, 0)return itemfrom math import gcd as GCDread=sys.stdin.readreadline=sys.stdin.readlinereadlines=sys.stdin.readlinesdef Power(x,n,f,e):if n==0:return es=edouble=xwhile n>=2:if n&1:s=f(s,double)double=f(double,double)n>>=1s=f(s,double)return sS=readline().rstrip()D=int(readline())if D==0:for s in S:if not s in "0?":ans=0breakelse:ans=1else:D%=9cnt=0su=Dmod=10**9+7for s in S:if s=="?":cnt+=1else:su-=int(s)su%=9def f(poly0,poly1):poly=[0]*9for i in range(9):for j in range(9):poly[(i+j)%9]+=poly0[i]*poly1[j]poly[(i+j)%9]%=modreturn polye=[0]*9e[0]=1x=[1]*9x[0]=2ans=Power(x,cnt,f,e)[su]if D==0:for s in S:if not s in "0?":breakelse:ans-=1ans%=modprint(ans)