#P5240. Polynomial Derivative Calculator

    ID: 18476 Type: Default 1000ms 256MiB

Polynomial Derivative Calculator

Polynomial Derivative Calculator

After learning about derivatives in calculus, Little R is given some derivative exercises by his math teacher. However, Little R isn't too interested in doing complex exercises. Instead, he wants you to help him design a program that computes the derivative of a given function.

Given a function in the form \(f(x) = a \cdot x^{b}\), your task is to compute its derivative \(f'(x)\). According to the rules of differentiation for power functions, if \(b \neq 0\), the derivative is:

\(f'(x) = a \cdot b \cdot x^{b-1}\)

If \(b = 0\) (i.e. \(f(x)\) is a constant function), the derivative is 0.

Note: Output the answer in the following format:

  • If \(b \neq 0\), output two space-separated integers: the coefficient \(a \cdot b\) and the new exponent \(b - 1\).
  • If \(b = 0\), output "0 0".

inputFormat

The input consists of a single line containing two integers a and b. These represent the function \(f(x) = a \cdot x^{b}\).

Constraints:

  • -103 ≤ a, b ≤ 103

outputFormat

Output a single line with two space-separated integers:

  • If b ≠ 0, output the derivative expressed as: the coefficient (a * b) and the new exponent (b - 1).
  • If b = 0, output 0 0.

sample

3 2
6 1