22010_PolynomialRemains

2022-5-16 18:21| 发布者: Hocassian| 查看: 21| 评论: 0|原作者: 肇庆学院ACM合集

摘要:
C:\Users\Administrator\Downloads\2019-10-12-10-14-4-8950637839899-Problem List-采集的数据-后羿采集器.html

Pro.ID

22010

Title

Polynomial Remains

Title链接

http://10.20.2.8/oj/exercise/problem?problem_id=22010

AC

0

Submit

0

Ratio

-

时间&空间限制

  • Time Limit: 600/300 MS (Java/Others)     Memory Limit: 32768/32768 K (Java/Others)
  • 描述

    Given the polynomial

    a(x) = an xn + ... + a1 x + a0,

    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

    a(x) = an xn + ... + a1 x + a0,

    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
    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

    样例输入

    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

    样例输出

    3 2
    -3 -1
    -2
    -1 2 -3
    0
    0
    1 2 3 4

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部