結果

問題 No.2215 Slide Subset Sum
ユーザー vwxyzvwxyz
提出日時 2023-09-06 19:39:37
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
MLE  
実行時間 -
コード長 1,439 bytes
コンパイル時間 685 ms
コンパイル使用メモリ 10,800 KB
実行使用メモリ 887,312 KB
最終ジャッジ日時 2023-09-06 19:39:52
合計ジャッジ時間 15,008 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 MLE -
testcase_01 MLE -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
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 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import bisect
import copy
import decimal
import fractions
import heapq
import itertools
import math
import random
import sys
import time
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
write=sys.stdout.write
#import pypyjit
#pypyjit.set_param('max_unroll_recursion=-1')

N,M,K=map(int,readline().split())
A=list(map(int,readline().split()))
mod=998244353
left=[[0]*K for i in range(N+1)]
right=[[0]*K for i in range(N+1)]
left[0][0]=1
right[N][0]=1
for i in range(1,N+1):
    if i%M==1:
        left[i][0]+=1
        left[i][A[i-1]%K]+=1
    else:
        for k in range(K):
            left[i][k]+=left[i-1][k]
            left[i][k]+=left[i-1][(k-A[i-1])%K]
for i in range(N-1,-1,-1):
    if i%M==0:
        right[i][0]=1
    else:
        for k in range(K):
            right[i][k]+=right[i+1][k]
            right[i][k]+=right[i+1][(k-A[i])%K]
for i in range(N-M+1):
    ans=(sum(right[i][k]*left[i+M][(-k)%K]%mod for k in range(K))-1)%mod
    print(ans)
0