Pro.ID22010 TitlePolynomial Remains Title链接http://10.20.2.8/oj/exercise/problem?problem_id=22010 AC0 Submit0 Ratio- 时间&空间限制描述Given the polynomial compute the remainder r(x) when a(x) is divided by xk+1. 输入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. 输出Description Given the polynomial compute the remainder r(x) when a(x) is divided by xk+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 Sample Output 3 2 Source 样例输入5 2 样例输出3 2 作者 |