CF1731F.Function Sum

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Suppose you have an integer array a1,a2,,ana_1, a_2, \dots, a_n .

Let lsl(i)\operatorname{lsl}(i) be the number of indices jj ( 1j<i1 \le j < i ) such that aj<aia_j < a_i .

Analogically, let grr(i)\operatorname{grr}(i) be the number of indices jj ( i<jni < j \le n ) such that aj>aia_j > a_i .

Let's name position ii good in the array aa if lsl(i)<grr(i)\operatorname{lsl}(i) < \operatorname{grr}(i) .

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

Given two integers nn and kk , find the sum of f(a)f(a) over all arrays aa of size nn such that 1aik1 \leq a_i \leq k for all 1in1 \leq i \leq n modulo 998244353998\,244\,353 .

输入格式

The first and only line contains two integers nn and kk ( 1n501 \leq n \leq 50 ; 2k<9982443532 \leq k < 998\,244\,353 ).

输出格式

Output a single integer — the sum of ff over all arrays aa of size nn modulo 998244353998\,244\,353 .

输入输出样例

  • 输入#1

    3 3

    输出#1

    28
  • 输入#2

    5 6

    输出#2

    34475
  • 输入#3

    12 30

    输出#3

    920711694

说明/提示

In the first test case:

f([1,1,1])=0f([1,1,1]) = 0 f([2,2,3])=2+2=4f([2,2,3]) = 2 + 2 = 4 f([1,1,2])=1+1=2f([1,1,2]) = 1 + 1 = 2 f([2,3,1])=2f([2,3,1]) = 2 f([1,1,3])=1+1=2f([1,1,3]) = 1 + 1 = 2 f([2,3,2])=2f([2,3,2]) = 2 f([1,2,1])=1f([1,2,1]) = 1 f([2,3,3])=2f([2,3,3]) = 2 f([1,2,2])=1f([1,2,2]) = 1 f([3,1,1])=0f([3,1,1]) = 0 f([1,2,3])=1f([1,2,3]) = 1 f([3,1,2])=1f([3,1,2]) = 1 f([1,3,1])=1f([1,3,1]) = 1 f([3,1,3])=1f([3,1,3]) = 1 f([1,3,2])=1f([1,3,2]) = 1 f([3,2,1])=0f([3,2,1]) = 0 f([1,3,3])=1f([1,3,3]) = 1 f([3,2,2])=0f([3,2,2]) = 0 f([2,1,1])=0f([2,1,1]) = 0 f([3,2,3])=2f([3,2,3]) = 2 f([2,1,2])=1f([2,1,2]) = 1 f([3,3,1])=0f([3,3,1]) = 0 f([2,1,3])=2+1=3f([2,1,3]) = 2 + 1 = 3 f([3,3,2])=0f([3,3,2]) = 0 f([2,2,1])=0f([2,2,1]) = 0 f([3,3,3])=0f([3,3,3]) = 0 f([2,2,2])=0f([2,2,2]) = 0 Adding up all of these values, we get 2828 as the answer.

首页