QOJ.ac

QOJ

Time Limit: 5 s Memory Limit: 512 MB Total points: 100 Hackable ✓

#13624. count

الإحصائيات

A sequence is called a "nice sequence" if it has length $n$, every number in the sequence is an integer between $1$ and $m$, and every integer from $1$ to $m$ appears at least once in the sequence.

For a sequence $A$, let $f_A(l, r)$ be the index of the maximum value in $A$ from the $l$-th to the $r$-th element (if there are multiple maximums, choose the one with the smallest index).

Two sequences $A$ and $B$ are isomorphic if and only if they have the same length and, for all $i \le j$, $f_A(i, j) = f_B(i, j)$.

Given $n$ and $m$, find the number of non-isomorphic nice sequences. The answer should be taken modulo $998244353$.

Input

A single line containing two positive integers $n$ and $m$.

Output

A single integer representing the number of non-isomorphic nice sequences.

Examples

Input 1

3 2

Output 1

4

Note 1

There are $6$ nice sequences in total: $2\ 1\ 1$, $1\ 2\ 1$, $1\ 1\ 2$, $1\ 2\ 2$, $2\ 1\ 2$, and $2\ 2\ 1$. Among these, $2\ 1\ 1$ and $2\ 2\ 1$ are isomorphic, and $1\ 2\ 1$ and $1\ 2\ 2$ are isomorphic. Therefore, there are $4$ non-isomorphic nice sequences.

Input 2

8 5

Output 2

1341

Input 3

100000 99999

Output 3

944488805

Input 4

300 200

Output 4

430256456

Input 5

2000 1000

Output 5

267823945

Input 6

100000 50000

Output 6

779381353

Subtasks

Subtask $n,m\leq$ Special Property Score
1 $8$ $10$
2 $100000$ $m\ge n-1$ $10$
3 $300$ $30$
4 $2000$ $20$
5 $100000$ $30$

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
EditorialOpen Official EditorialQingyu- Download

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.