Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|

Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |

Language: Polynomial Remains
Description Given the polynomial
_{n} x^{n} + ... + a_{1} x + a_{0}, compute the remainder r(x) when a(x) is divided by x ^{k}+1.Input The input consists of a number of cases. The first line of each case specifies the two integers n and k (0 <= n, k <= 10000). The next n+1 integers give the coefficients of a(x), starting from a0 and ending with an. The input is terminated if n = k = -1. Output For each case, output the coefficients of the remainder on one line, starting from the constant coefficient r0. If the remainder is 0, print only the constant coefficient. Otherwise, print only the first d+1 coefficients for a remainder of degree d. Separate the coefficients by a single space.
You may assume that the coefficients of the remainder can be represented by 32-bit integers. Sample Input 5 2 6 3 3 2 0 1 5 2 0 0 3 2 0 1 4 1 1 4 1 1 1 6 3 2 3 -3 4 1 0 1 1 0 5 1 0 0 7 3 5 1 2 3 4 -1 -1 Sample Output 3 2 -3 -1 -2 -1 2 -3 0 0 1 2 3 4 Source |

[Submit] [Go Back] [Status] [Discuss]

All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di

Any problem, Please Contact Administrator