#P1567. Count the Arrays

Count the Arrays

题目描述

Your task is to calculate the number of arrays such that:

  • each array contains nn elements;
  • each element is an integer from 11 to mm;
  • for each array, there is exactly one pair of equal elements;
  • for each array aa, there exists an index ii such that the array is strictly ascending before the ii-th element and strictly descending after it (formally, it means that aj a_j < aj+1a_{j + 1}, if jj < ii, and aja_j > aj+1a_{j + 1}, if i).\ge i).

中文题目

求满足如下条件的数列个数,答案对998244353998244353取模: 长度为nn 每个元素值域为11mm 有且仅有一对相等的元素 存在下标ii,满足a1<<ai1<ai>ai+1>>ana_1<· · ·<a_{i−1}<a_i >a_{i+1}>· · ·>a_n 数据范围:n,m2×105n,m≤2×10^5

输入描述

The first line contains two integers nn and mm (2nm21052 \le n \le m \le 2 \cdot 10^5).

输出描述

Print one integer — the number of arrays that meet all of the aforementioned conditions, taken modulo 998244353998244353.

样例

3 4
6
3 5
10

42 1337
806066790

100000 200000

707899035

提示

The arrays in the first example are:

  • [1,2,1][1, 2, 1];
  • [1,3,1][1, 3, 1];
  • [1,4,1][1, 4, 1];
  • [2,3,2][2, 3, 2];
  • [2,4,2][2, 4, 2];
  • [3,4,3][3, 4, 3].