CF1731F.Function Sum
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Suppose you have an integer array a1,a2,…,an .
Let lsl(i) be the number of indices j ( 1≤j<i ) such that aj<ai .
Analogically, let grr(i) be the number of indices j ( i<j≤n ) such that aj>ai .
Let's name position i good in the array a if lsl(i)<grr(i) .
Finally, let's define a function f on array a f(a) as the sum of all ai 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≤ai≤k for all 1≤i≤n modulo 998244353 .
输入格式
The first and only line contains two integers n and k ( 1≤n≤50 ; 2≤k<998244353 ).
输出格式
Output a single integer — the sum of f over all arrays a of size n modulo 998244353 .
输入输出样例
输入#1
3 3
输出#1
28
输入#2
5 6
输出#2
34475
输入#3
12 30
输出#3
920711694
说明/提示
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.