Math Tutoring
Time limit1sMemory limit128 MB
Read each polynomial's degree and coefficients and print the coefficients of its derivative in the same format.
- Level
Easy1 of 10
- Topics
- Math, Implementation
- Solved
- No attempts yet
Problem
You are teaching a friend the rule for differentiating a polynomial, and no matter how many examples you work through, the rule does not stick. So you decide to write a program that computes the derivative for him.
Differentiating the polynomial
gives
For example, the derivative of is , and the derivative of is .
Given a polynomial, print its derivative. Only polynomials of the form shown above appear in this problem.
Input
The first line contains the number of test cases.
Each test case is given on a single line. The first integer on the line is the highest exponent () of the polynomial, followed by coefficients, one for each term from down to . Every coefficient is an integer between and , inclusive. The highest exponent is always positive. All numbers are separated by a single space.
Output
Print one line for each test case. The line starts with Case x:, where is the test case number counting from 1. Put a single space after the colon and then write the derivative.
Write the derivative in the same format as the input. The first value is the highest exponent of the derivative, followed by its coefficients from down to . Separate the values with a single space, and print the leading coefficient even when it is 0.