#P10007. [集训队互测 2023] 童话
[集训队互测 2023] 童话
Background
A fairy tale is only beautiful in truth, yet it is never continued.
A fairy tale is only beautiful in gentleness, yet it is never continued.
Problem Description
Lingluo has recently been learning the prefix sum algorithm, and she wrote the following program:
read(n),read(a);
for(int i=0;i<=n;i++)read(f[i]);
for(int t=1;t<=n;t++){
for(int i=1;i<=n;i++)f[i]=f[i]+a*f[i-1];
ans[t]=f[t];
}
She found that when is relatively large, this program will time out. Please help write a program to compute . Since the answers are too large, you only need to output each number modulo .
Input Format
The first line contains two positive integers .
The next line contains non-negative integers, representing .
Output Format
Output non-negative integers, representing .
2 1
1 2 0
3 7
10 10
5 9 7 8 0 6 3 2 4 10 1
59 1687 55618 1937320 69557006 549579657 621247830 250099579 483510144 968467040
Hint
Constraints:
For of the testdata, it is guaranteed that , , and .
| Subtask ID | Special Property | Score | |
|---|---|---|---|
| A | |||
| BC | |||
| BD | |||
| C | |||
Special Property A: It is guaranteed that the number of indices such that does not exceed .
Special Property B: It is guaranteed that .
Special Property C: It is guaranteed that for all , .
Special Property D: It is guaranteed that for all , .
Translated by ChatGPT 5