Binomial Theorem

3

17 votes
Medium
Problem

Description

You are tasked to determine the kth term of the binomial expansion of the expression (x+y)n.

Input Format

The input starts with an integer M > 0, followed by M pairs of integers k, n, where 1kn+1 and 0<n<1000.

Output Format

For every pair of integers k, n, output the correct kth term of the binomial expansion of (x+y)n. If the coefficient is 1, the coefficient should not be printed. If the power of x is 0, the variable x should not be printed. If the power of y is 0, the variable y should not be printed. If the power of x is 1, the power of variable x should not be printed. If the power of y is 1, the power of variable y should not be printed. In general, the format of each output is cxayb, where c is the coefficient, a is the power of x and b is the power of y.

Time Limit: 2
Memory Limit: 256
Source Limit:
Editor Image

?