P10254 Stutter

Background

There is a formal statement of the problem at the end of the description.

Description

Because of practicing rap, ZHY has become a stutterer. ZHY’s stutter is very special. Specifically, suppose ZHY wants to read a passage with $n$ characters. Then he will read the first character once, the second character twice, the third character three times, ... and the $n$-th character $n$ times. For example, “原神启动” would be read by ZHY as “原神神启启启动动动动”. YHZ has $n$ characters in hand. Each character has a pleasantness value $a_i$ set by YHZ, and $a_{1\sim n}$ forms a permutation of $1\sim n$. Now, he wants to rearrange these $n$ characters into a passage for ZHY to read. Since YHZ likes playing Genshin Impact (Yuánshén), he requires that after rearrangement, the number of inversions in the sequence $a$ is exactly $k$. However, YHZ has not decided the order of the characters yet, so please compute, over all possible permutations, the sum of the total pleasantness values of all characters that YHZ will hear when ZHY reads the passage in order. Obviously, if YHZ hears a character multiple times, its pleasantness value should be counted multiple times in the total. **Formal statement** A permutation $a_1,a_2,\cdots,a_n$ of $1\sim n$ is called valid if and only if its number of inversions is **exactly** $k$. Also, for a permutation $a_1,a_2,\cdots,a_n$, its weight is $\sum_{i=1}^n i\times a_i$. Given $n$ and $k$, please compute the sum of weights of all valid permutations of $1\sim n$, modulo $998244353$. The number of inversions of a permutation is defined as $\sum_{i=1}^n\sum_{j=i+1}^n [a_i>a_j]$.

Input Format

One line with two integers $n,k$.

Output Format

One line with one integer, the answer modulo $998244353$.

Explanation/Hint

**Sample $1$ explanation** There are only two valid permutations: $2\ 3\ 1$ and $3\ 1\ 2$. Their weights are both $11$, so the answer is $22$. --- For $10\%$ of the testdata, $n \le 10$. For $25\%$ of the testdata, $n \le 100$. For another $20\%$ of the testdata, $k \le 300$. For $100\%$ of the testdata, $1 \le n \le 300$, $0\le k \le \frac{n(n-1)}{2}$. Translated by ChatGPT 5