Sum Mod Pair of A
시간 제한1.5초메모리 제한1024 MB
배열에 합 모듈러 쌍 연산을 K번 적용해 얻은 배열의 모든 원소 합을 998244353으로 나눈 나머지를 구합니다.
문제
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 (indexed from to ) and an integer of a power of , the operation returns an array of size (indexed from to ) where its th element is with and .
For example, let and . 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 operation. He then introduces the following for a positive integer .
For example, let and .
- → ( elements)
- → ( elements)
Jono would like to experiment with a large 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 .
Your task in this problem is to compute the sum of all elements in the array produced by . Output the non-negative remainder after being divided by .
입력
Input begins with a line containing three integers (; ; ) representing the size of array , and the parameter and for the operation, respectively. The next line contains integers () representing the array .
출력
Output contains an integer in a line representing the non-negative remainder of the sum of all elements in after being divided by .