Score : 400 points
问题描述
我们有一个次数为 N 的多项式,A(x)=ANxN+AN−1xN−1+⋯+A1x+A0,
和另一个次数为 M 的多项式,B(x)=BMxM+BM−1xM−1+⋯+B1x+B0。
这里,A(x) 和 B(x) 的每个系数都是绝对值不大于 100 的整数,并且首项系数不为 0。
同时,令它们的乘积为 $C(x)=A(x)B(x)=C_{N+M}x^{N+M}+C_{N+M-1}x^{N+M-1}+\cdots +C_1x+C_0$。
给定 A0,A1,…,AN 和 C0,C1,…,CN+M,求解 B0,B1,…,BM。
注意,所给输入保证存在唯一的一组序列 B0,B1,…,BM 满足上述条件。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
We have a polynomial of degree N, A(x)=ANxN+AN−1xN−1+⋯+A1x+A0,
and another of degree M, B(x)=BMxM+BM−1xM−1+⋯+B1x+B0.
Here, each coefficient of A(x) and B(x) is an integer whose absolute value is at most 100, and the leading coefficients are not 0.
Also, let the product of them be $C(x)=A(x)B(x)=C_{N+M}x^{N+M}+C_{N+M-1}x^{N+M-1}+\cdots +C_1x+C_0$.
Given A0,A1,…,AN and C0,C1,…,CN+M, find B0,B1,…,BM.
Here, the given inputs guarantee that there is a unique sequence B0,B1,…,BM that satisfies the given conditions.
Constraints
- 1≤N<100
- 1≤M<100
- ∣Ai∣≤100
- ∣Ci∣≤106
- AN=0
- CN+M=0
- There is a unique sequence B0,B1,…,BM that satisfies the conditions given in the statement.
Input is given from Standard Input in the following format:
N M
A0 A1 … AN−1 AN
C0 C1 … CN+M−1 CN+M
Output
Print the M+1 integers B0,B1,…,BM in one line, with spaces in between.
1 2
2 1
12 14 8 2
Sample Output 1
6 4 2
For A(x)=x+2 and B(x)=2x2+4x+6, we have C(x)=A(x)B(x)=(x+2)(2x2+4x+6)=2x3+8x2+14x+12, so B(x)=2x2+4x+6 satisfies the given conditions. Thus, B0=6, B1=4, B2=2 should be printed in this order, with spaces in between.
1 1
100 1
10000 0 -1
Sample Output 2
100 -1
We have A(x)=x+100, C(x)=−x2+10000, for which B(x)=−x+100 satisfies the given conditions. Thus, 100, −1 should be printed in this order, with spaces in between.
update @ 2024/3/10 10:31:37