Codeforces Round 841 (Div. 2) and Divide by Zero 2022
F
Function Sum
Codeforces
2500
原题
← E→
翻译中…

Suppose you have an integer array $a_1, a_2, \dots, a_n$.

翻译中…

Let $\operatorname{lsl}(i)$ be the number of indices $j$ ($1 \le j \lt i$) such that $a_j \lt a_i$.

翻译中…

Analogically, let $\operatorname{grr}(i)$ be the number of indices $j$ ($i \lt j \le n$) such that $a_j \gt a_i$.

翻译中…

Let's name position $i$ good in the array $a$ if $\operatorname{lsl}(i) \lt \operatorname{grr}(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 \leq a_i \leq k$ for all $1 \leq i \leq n$ modulo $998\,244\,353$.

翻译中…

Input

翻译中…

The first and only line contains two integers $n$ and $k$ ($1 \leq n \leq 50$; $2 \leq k \lt 998\,244\,353$).

翻译中…

Output

翻译中…

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]) = 0$$f([2,2,3]) = 2 + 2 = 4$$f([1,1,2]) = 1 + 1 = 2$$f([2,3,1]) = 2$$f([1,1,3]) = 1 + 1 = 2$$f([2,3,2]) = 2$$f([1,2,1]) = 1$$f([2,3,3]) = 2$$f([1,2,2]) = 1$$f([3,1,1]) = 0$$f([1,2,3]) = 1$$f([3,1,2]) = 1$$f([1,3,1]) = 1$$f([3,1,3]) = 1$$f([1,3,2]) = 1$$f([3,2,1]) = 0$$f([1,3,3]) = 1$$f([3,2,2]) = 0$$f([2,1,1]) = 0$$f([3,2,3]) = 2$$f([2,1,2]) = 1$$f([3,3,1]) = 0$$f([2,1,3]) = 2 + 1 = 3$$f([3,3,2]) = 0$$f([2,2,1]) = 0$$f([3,3,3]) = 0$$f([2,2,2]) = 0$

翻译中…

Adding up all of these values, we get $28$ as the answer.

翻译中…

样例

Input #1
3 3
Output #1
28
InputCopy OutputCopy
Input #2
5 6
Output #2
34475
InputCopy OutputCopy
Input #3
12 30
Output #3
920711694
InputCopy OutputCopy
题目信息
题号
1731F
时间限制
4 s
内存限制
256 MB
标签
暴力
组合数学
动态规划
FFT
数学

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。