#P7431. [THUPC 2017] 小 L 的计算题

    ID: 8299 远端评测题 3000ms 500MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>2017分治快速傅里叶变换 FFT快速数论变换 NTTTHUPC

[THUPC 2017] 小 L 的计算题

Problem Description

You are given a non-negative integer array {ai}\{a_i\} of length nn. Little L defines a magical transform:

fk=(i=1naik)mod998244353f_k=\left(\sum_{i=1}^na_i^k\right)\bmod 998244353

Little L plans to do something interesting with the sequence ff generated by this transform, but he is not good at multiplication, so he asks you for help and hopes you can compute f1nf_{1\dots n} as quickly as possible.

Input Format

The input contains multiple test cases.

The first line contains an integer TT, which indicates the number of test cases.

The next 2T2T lines describe the test cases, with every two lines forming one test case.

In each test case, the first line contains an integer nn, which is the length of the array {ai}\{a_i\}. The next line contains nn integers describing the array {ai}\{a_i\}.

It is guaranteed that the input aia_i satisfy 0ai1090\le a_i\le10^9. In one test file, it is guaranteed that n4×105\sum n\le 4\times 10^5.

Output Format

We do not want you to output too many numbers. Therefore, let ans=i=1nfians=\bigoplus_{i=1}^{n}f_i, where \bigoplus denotes the XOR operation, which can be written as ^ in C++ / Java / Python.

For each test case, output one integer per line, representing ansans.

2
3
2 3 3
5
1 2 3 4 5
32
4675

Hint

For 100%100\% of the testdata, 0ai1090\le a_i\le10^9, 1n2×1051\le n\le 2\times 10^5, and n4×105\sum n\le 4\times 10^5.

From THUPC (THU Programming Contest, Tsinghua University Programming Contest) 2017.

Translated by ChatGPT 5