luogu#P4191. [CTSC2010] 性能优化
[CTSC2010] 性能优化
Background
Description
Programmer Xiao Ming is developing a large software system. There is a core routine described by the following pseudocode (assume all variables are initially , and that none of the data types will overflow):
Input a[0], a[1], ... , a[n - 1], b[0], b[1], ... , b[n - 1], C
For i: 0 to n - 1
x[0, i] = a[i]
For i: 0 to C - 1
For j: 0 to n - 1
For k: 0 to n - 1
x[i + 1, (j + k) mod n] = x[i + 1, (j + k) mod n] + b[k]x[i, j]
Output x[C, 0] mod (n + 1), x[C, 1] mod (n + 1), ... , x[C, n - 1] mod (n + 1)
However, this program is very inefficient; its time complexity is . He wants you to optimize this program while producing the same output. To make the problem easier, he guarantees that the input can be written as a product of some positive integers, each no greater than , and that is prime.
Output Format
Output contains lines, one number per line. The -th line is the value of . You should ensure each printed number is between and inclusive.
4 1
1 2 3 4
4 3 3 1
2
1
0
2
Hint
There are test points in total. Constraints:
| Test Point | ||
|---|---|---|
| 1 | ||
| 2 | ||
| 3 | ||
| 4 | ||
| 5 | ||
| 6 | ||
| 7 | ||
| 8 | ||
| 9 | ||
| 10 |
In all testdata, and do not exceed .
Translated by ChatGPT 5