問題一覧 > 通常問題

No.2347 Swap!!

レベル : / AI推定難易度 : 2600 / 実行時間制限 : 1ケース 5.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (解説公開後に AC するまで非表示) / 解いたユーザー数 8
作問者 : ytqm3 / テスター : 👑 Forested ぷら
お気に入りにしたユーザー ProblemId : 9519 / 自分の提出
問題文最終更新日: 2023-06-09 20:21:53
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 392 (順位表) の他の問題:

Problem Statement

For sequences $p,q$, define $d(p,q)$ as "the minimum number of operations needed to make $p$ equal to $q$ by repeatedly performing the operation of swapping adjacent elements of $p$ (or $0$ if this is impossible)".

Find the sum of $d(a,b)$ over all pairs $(a,b)$ of sequences of length $N$ consisting of integers between $1$ and $M$, inclusive, modulo $998244353$.

Input

$N$ $M$
  • $1 \le N,M \le 10^5$
  • All inputs are integers.

Output

Output the answer.

Sample

Sample 1
Input
2 2
Output
2

For $(a,b)=((0,1),(1,0)),((1,0),(0,1))$, we have $d(a,b)=1$. In all other cases it is $0$, so the answer is $2$.

Sample 2
Input
1 2
Output
0
Sample 3
Input
314 159
Output
691219959

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。