Sum Mod Pair of A
Time limit1.5sMemory limit1024 MB
Given array A and a power of 2 M, find the sum of all elements of SMPA^K(A, M) modulo 998244353 when K can be as large as 10^9.
- Level
Medium6 of 10
- Topics
- Math, Number theory, Array
- Solved
- No attempts yet
Statement
Jono likes arrays. He is especially interested in one operation on an array, which he calls Sum Mod Pair of A, or SMPA for short.
Given an array of integers (indexed from to ) and an integer that is a power of , the operation returns an array of size (indexed from to ). Its th element is , where and .
For example, let be {2, 4, 5} and . Then is {4, 6, 7, 6, 0, 1, 7, 1, 2}.
Jono is not satisfied with one SMPA operation. He defines for a positive integer as follows. If , . Otherwise, .
For example, let be {1, 2} and . Then is {2, 3, 3, 4}, and is {4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 0}.
The array size grows exponentially, so Jono cannot print the result. He only needs the sum of all elements of . Compute that sum modulo 998244353.
Input
The first line contains three integers , , and (, , ). The next line contains integers (), the elements of array .
Output
Print one integer on a line: the non-negative remainder of the sum of all elements of divided by 998244353.