問題一覧 > 通常問題

No.1757 Many Many Cards

レベル : / AI推定難易度 : 2200 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (解説公開後に AC するまで非表示) / 解いたユーザー数 42
作問者 : PCTprobability / テスター : NyaanNyaan tokusakurai
お気に入りにしたユーザー ProblemId : 7231 / 自分の提出
問題文最終更新日: 2021-11-20 20:44:20
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 324 (順位表) の他の問題:

Problem Statement

PCT created the following problem.

Many Cards

There are $X$ cards, and on the $i$-th card you can write either $A_i$ or $B_i$.

Find the maximum number of distinct integers written on the cards when you can freely choose which integer to write on each card.

Since this problem was far too easy for Nyaan, PCT changed it as follows.

Many Many Cards

You are given $N,M$. Among the inputs of Many Cards, there are $M^{2N}$ inputs such that $X=N$, $A_i,B_i$ are integers, and $1 \le A_i,B_i \le M$. Find the sum of the answers over all of them, modulo $998244353$.

Solve Many Many Cards.

Constraints

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

Input

$N\ M$

Output

Output the answer on $1$ line.

Sample

Sample 1
Input
2 3
Output
159

For example, when $A=(1,2),B=(2,2)$, you can write $2$ distinct integers by writing $1$ on card number $1$ and $2$ on card number $2$.

Also, it can be proved that you cannot write $3$ or more distinct integers, so the answer in this case is $2$.

The sum of the answers over all $81$ possible inputs is $159$.

Sample 2
Input
5 4
Output
3941788

Sample 3
Input
2021 1120
Output
458917605

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