#P6296. 轮换式 加强版

    ID: 5284 远端评测题 2000ms 256MiB 尝试: 0 已通过: 0 难度: 9 上传者: 标签>数学递推生成函数快速傅里叶变换 FFT

轮换式 加强版

Description

Xiao Ben found that for any nn letters, the rotational form they form can be expressed as a linear combination of nn basic rotational forms.

Unary basic rotational form: aa;

Binary: a+ba+b, abab;

Ternary: a+b+ca+b+c, ab+ac+bcab+ac+bc, abcabc;

Quaternary: a+b+c+da+b+c+d, ab+ac+ad+bc+bd+cdab+ac+ad+bc+bd+cd, abc+abd+bcdabc+abd+bcd, abcdabcd;

......

Given the values of all basic rotational forms of nn numbers, find the sum of their mm-th powers. Output the answer modulo 899678209899678209 (899678209=429×221+1899678209 = 429 \times 2^{21} + 1).

Input Format

The first line contains two positive integers n,mn, m, with meanings as described in the statement.
The next line contains nn positive integers. The ii-th number is aia_i, representing the value of the ii-th basic rotational form of nn variables.

Output Format

Output one integer in one line, representing the answer.

2 2
9 18
45
9 233333
9 1 8 7 5 6 3 4 2
100006329

Hint

[Explanation for Sample 1]
We can write the equations a+b=9a+b = 9 and ab=18ab = 18, and it is easy to compute a2+b2=45a^2+b^2 = 45.

[Constraints]

  • For 20%20\% of the testdata, 1n10001 \le n \le 1000, 1m1041 \le m \le 10^4;
  • For 60%60\% of the testdata, 1n10001 \le n \le 1000, 1m1091 \le m \le 10^9;
  • For 100%100\% of the testdata, 1n3×1041 \le n \le 3 \times 10^4, 1m1091 \le m \le 10^9, 1ai1081 \le a_i \le 10^8.

Translated by ChatGPT 5