← Home
write a go solution for Description:
Suppose you have an integer array a_1,a_2,...,a_n.

Let operatornamelsl(i) be the number of indices j (1<=j<i) such that a_j<a_i.

Analogically, let operatornamegrr(i) be the number of indices j (i<j<=n) such that a_j>a_i.

Let's name position i good in the array a if operatornamelsl(i)<operatornamegrr(i).

Finally, let's define a function f on array a f(a) as the sum of all a_i such that i is good in a.

Given two integers n and k, find the sum of f(a) over all arrays a of size n such that 1<=qa_i<=qk for all 1<=i<=n modulo 998,244,353.

Input Format:
The first and only line contains two integers n and k (1<=n<=50; 2<=k<998,244,353).

Output Format:
Output a single integer — the sum of f over all arrays a of size n modulo 998,244,353.

Note:
In the first test case:

f([1,1,1])=0f([2,2,3])=2+2=4f([1,1,2])=1+1=2f([2,3,1])=2f([1,1,3])=1+1=2f([2,3,2])=2f([1,2,1])=1f([2,3,3])=2f([1,2,2])=1f([3,1,1])=0f([1,2,3])=1f([3,1,2])=1f([1,3,1])=1f([3,1,3])=1f([1,3,2])=1f([3,2,1])=0f([1,3,3])=1f([3,2,2])=0f([2,1,1])=0f([3,2,3])=2f([2,1,2])=1f([3,3,1])=0f([2,1,3])=2+1=3f([3,3,2])=0f([2,2,1])=0f([3,3,3])=0f([2,2,2])=0

Adding up all of these values, we get 28 as the answer.. Output only the code with no comments, explanation, or additional text.