No.1757 Many Many Cards
タグ : / 解いたユーザー数 42
作問者 :
PCTprobability
/ テスター :
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もしくは右上の雲マークをクリックしてアカウントを作成してください。