eolymp
bolt
Попробуйте наш новый интерфейс для отправки задач
Задачи

Faulhaber`s Triangle

Faulhaber`s Triangle

Лимит времени 1 секунда
Лимит использования памяти 32 MiB

The sum of the m-th powers of the first n integers

can be written as a polynomial of degree m+1 in n:

For example:

S(n, 1) = (1 + ... + n) = (1/2) * n2 + (1/2) * n

S(n, 2) = (1 + ... + n2) = (1/3) * n3 + (1/2) * n2 + (1/6) * n

S(n, 3) = (1 +...+ n3) = (1/4) * n4 + (1/2) * n3) + (1/4) * n2

S(n, 4) = (1 +...+ n4) = (1/5) * n5 + (1/2) * n4) + (1/3) * n3 - (1/30) * n

The coefficients F(m, k) of these formulas form Faulhaber's Triangle:

where rows m start with 0 (at the top) and columns k go from 1 to m+1

Each row of Faulhaber's Triangle can be computed from the previous row by:

a) The element in row i and column j (j > 1) is (i/j) * (the element above left); that is: F(i, j) = (i/j) * F(i-1, j-1)

b) The first element in each row F(i, 1) is chosen so the sum of the elements in the row is 1.

Write a program to find entries in Faulhaber's Triangle as decimal fractions in lowest terms.

Входные данные

The first line of input contains a single integer P, (1P1000), which is the number of data sets that follow. Each data set should be processed identically and independently.

Each data set consists of a single line of input consisting of three space separated decimal integers. The first integer is the data set number. The second integer is row number m, and the third integer is the index k within the row of the entry for which you are to find F(m, k), the Faulhaber's Triangle entry (0m400, 1km+1).

Выходные данные

For each data set there is a single line of output. It contains the data set number, followed by a single space which is then followed by either the value if it is an integer OR by the numerator of the entry, a forward slash and the denominator of the entry.

Пример

Входные данные #1
4
1 4 1
2 4 3
3 86 79
4 400 401
Выходные данные #1
1 -1/30
2 1/3
3 -22388337
4 1/401