#P5373. 【模板】多项式复合函数
【模板】多项式复合函数
Background
One day, NaCly_Fish saw say in the group chat: “I finally finished writing polynomial composition! qwq”.
So she curiously asked : “How do you write this thing?”.
only threw her a PDF in “Yingwen” (pinyin), but she could not understand it at all.
So she asked you for help, hoping you can help her solve this difficult problem.
Problem Description
Given an -degree polynomial and an -degree polynomial , you need to find an -degree polynomial that satisfies:
In other words, the polynomial you need should satisfy:
$$H(x) \equiv \sum\limits_{i=0}^n [x^i]F(x)\times G(x)^i \space (\text{mod }x^{n+1})$$Take all coefficients of the result modulo .
Input Format
The first line contains two positive integers , representing the degrees of and .
The second line contains non-negative integers , representing the coefficient of the term of .
The third line contains non-negative integers , representing the coefficient of the term of .
Output Format
Output one line with non-negative integers, from low degree to high degree, representing the coefficients of .
5 1
1 9 2 6 0 8
1 7
26 497 4900 29498 96040 134456
Hint
Constraints:
Translated by ChatGPT 5