403220: GYM101081 C Salt Mine

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

C. Salt Minetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output

Wieliczka city in Poland is known for its imposing salt mine. The extraction of salt must obey important restrictions, since the walls and ceiling must stay stable as the good is being extracted. Engineering studies show that the production of salt of a mine can be modeled by a polinomial A(x) (where x is the total volume extracted from the mine). It is know that after a day of work, when x0 material was extracted from the mine, the production now becomes q(x) and there is a waste of r where A(x) = q(x)(x - x0) + r.

Your task id, given A(x) and an integer x0, determine the waste r and the new polynomial related to the new production capacity q(x).

Input

The first line has an integer T, the number of test cases.

Each test case begins with two integers n and x0, the number of terms in the polynomial and the quantity of extracted salt. The following line has n + 1 integers, the coefficients of A(x). The ith integer on the line is the coefficient of xi - 1.

Limits

  • 1 ≤ T ≤ 104
  • 1 ≤ n ≤ 15
  • 1 ≤ x0 ≤ 50
  • Each coefficient is between 0 and 100
Output

For each test, print the waste r and then a line with n integers, the polynomial q(x). The ith integer in that line is the coefficient of xi - 1 in q(x). It is guaranteed all terms in the output will fit in a 64-bit signed integer.

ExampleInput
3
2 3
3 2 4
3 7
1 10 5 7
1 30
1 0
Output
45
14 4
2717
388 54 7
1
0

Source/Category

加入题单

上一题 下一题 算法标签: