atcoder#ARC106D. [ARC106D] Powers

[ARC106D] Powers

Score : 600600 points

Problem Statement

Given are integer sequence of length NN, A=(A1,A2,,AN)A = (A_1, A_2, \cdots, A_N), and an integer KK.

For each XX such that 1XK1 \le X \le K, find the following value:

$\left(\displaystyle \sum_{L=1}^{N-1} \sum_{R=L+1}^{N} (A_L+A_R)^X\right) \bmod 998244353$

Constraints

  • All values in input are integers.
  • 2N2×1052 \le N \le 2 \times 10^5
  • 1K3001 \le K \le 300
  • 1Ai1081 \le A_i \le 10^8

Input

Input is given from Standard Input in the following format:

NN KK

A1A_1 A2A_2 \cdots ANA_N

Output

Print KK lines.

The XX-th line should contain the value $\left(\displaystyle \sum_{L=1}^{N-1} \sum_{R=L+1}^{N} (A_L+A_R)^X \right) \bmod 998244353$.

3 3
1 2 3
12
50
216

In the 11-st line, we should print (1+2)1+(1+3)1+(2+3)1=3+4+5=12(1+2)^1 + (1+3)^1 + (2+3)^1 = 3 + 4 + 5 = 12.

In the 22-nd line, we should print (1+2)2+(1+3)2+(2+3)2=9+16+25=50(1+2)^2 + (1+3)^2 + (2+3)^2 = 9 + 16 + 25 = 50.

In the 33-rd line, we should print (1+2)3+(1+3)3+(2+3)3=27+64+125=216(1+2)^3 + (1+3)^3 + (2+3)^3 = 27 + 64 + 125 = 216.

10 10
1 1 1 1 1 1 1 1 1 1
90
180
360
720
1440
2880
5760
11520
23040
46080
2 5
1234 5678
6912
47775744
805306038
64822328
838460992

Be sure to print the sum modulo 998244353998244353.