#P4512. 【模板】多项式除法
【模板】多项式除法
Description
Given an -degree polynomial and an -degree polynomial , find polynomials and such that:
- , and .
- .
All operations are performed modulo .
Input Format
The first line contains two integers and , as described above.
The second line contains integers, giving the coefficients of from low to high degree.
The third line contains integers, giving the coefficients of from low to high degree.
Output Format
The first line contains integers, giving the coefficients of from low to high degree.
The second line contains integers, giving the coefficients of from low to high degree.
If , pad the remaining coefficients with .
5 1
1 9 2 6 0 8
1 7
237340659 335104102 649004347 448191342 855638018
760903695
Hint
For all testdata, , and the given coefficients belong to .
Translated by ChatGPT 5
京公网安备 11011102002149号