Logo
(追記) (追記ここまで)

27631번 - Sum Mod Pair of A 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1.5 초 1024 MB176440.000%

문제

Jono likes arrays. Jono is quite interested in one particular type of operation on an array that he calls Sum Mod Pair of A, or SMPA for short.

Given an array of integers $A$ (indexed from 0ドル$ to $N - 1$) and an integer $M$ of a power of 2ドル,ドル the operation $\text{SMPA}(A, M)$ returns an array of size $N^2$ (indexed from 0ドル$ to $N^2-1$) where its $i$th element is $(A_x+A_y) \bmod M$ with $x = \lfloor i/N \rfloor$ and $y = i \bmod N$.

For example, let $A_{0..2} = \{2, 4, 5\}$ and $M = 8$. Then,

$$\begin{align*} \text{SMPA}(A, M) = ,円& \{ (A_0 + A_0) \bmod M,(A_0 + A_1) \bmod M,(A_0 + A_2) \bmod M, \\ & (A_1 + A_0) \bmod M,(A_1 + A_1) \bmod M,(A_1 + A_2) \bmod M, \\ & (A_2 + A_0) \bmod M,(A_2 + A_1) \bmod M,(A_2 + A_2) \bmod M \} \\ = ,円& \{ (2 + 2) \bmod 8,(2 + 4) \bmod 8,(2 + 5) \bmod 8, \\ & (4 + 2) \bmod 8,(4 + 4) \bmod 8,(4 + 5) \bmod 8, \\ & (5 + 2) \bmod 8,(5 + 4) \bmod 8,(5 + 5) \bmod 8 \} \\ = ,円& \{4, 6, 7, 6, 0, 1, 7, 1, 2\} \end{align*}$$

Jono is not satisfied with only one $\text{SMPA}$ operation. He then introduces the following $\text{SMPA}^K$ for a positive integer $K$.

$$\text{SMPA}^K(A, M) = \begin{cases}\text{SMPA}(A, M), & \text{if }K = 1 \\ \text{SMPA}^{K-1}(\text{SMPA}(A, M), M), & \text{otherwise}\end{cases}$$

For example, let $A_{0..1} = \{1, 2\}$ and $M = 8$.

  • $\text{SMPA}^1 (A, M) = \{2, 3, 3, 4\}$
  • $\text{SMPA}^2 (A, M) = \{4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 0\}$
  • $\text{SMPA}^3 (A, M) = \{0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4, 1, 2, 2, 3, \dots \}$ → (256ドル$ elements)
  • $\text{SMPA}^4 (A, M) = \{0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4, 1, 2, 2, 3, \dots \}$ → (65536ドル$ elements)

Jono would like to experiment with a large $K$ but, as you might already notice, the array size grows exponentially. Therefore, he cannot simply print out the resulting array. Instead, he will be satisfied if he knows the sum of all elements in the resulting array. As this number can be very large as well, he decides to modulo the output by 998ドル,244円,353円$.

Your task in this problem is to compute the sum of all elements in the array produced by $\text{SMPA}^K(A, M)$. Output the non-negative remainder after being divided by 998ドル,244円,353円$.

입력

Input begins with a line containing three integers $N$ $M$ $K$ (1ドル ≤ N ≤ 100,000円$; $M ∈ \{2^0 , 2^1 , \dots , 2^{18}\}$; 1ドル ≤ K ≤ 10^9$) representing the size of array $A,ドル and the parameter $M$ and $K$ for the $\text{SMPA}^K(A, M)$ operation, respectively. The next line contains $N$ integers $A_i$ (0ドル ≤ A_i < M$) representing the array $A$.

출력

Output contains an integer in a line representing the non-negative remainder of the sum of all elements in $\text{SMPA}^K(A, M)$ after being divided by 998ドル,244円,353円$.

제한

예제 입력 1

3 8 1
0 1 2

예제 출력 1

18

$\text{SMPA}^1 (\{0, 1, 2\}, 8) = \{0, 1, 2, 1, 2, 3, 2, 3, 4\}$. The sum of all its elements is 0ドル+1+たす2+たす1+たす2+たす3+たす2+たす3+たす4 = 18$.

예제 입력 2

3 8 2
0 1 2

예제 출력 2

316

예제 입력 3

5 8192 3
1000 2000 3000 4000 5000

예제 출력 3

577938879

The sum of all elements in the resulting array is 1ドル,576円,183円,232円$. Its non-negative remainder after being divided by 998ドル,244円,353円$ is 577ドル,938円,879円$.

힌트

출처

ICPC > Regionals > Asia Pacific > Indonesia > Indonesia National Contest > INC 2021 J번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /