QOJ.ac

QOJ

時間限制: 3.0 s 記憶體限制: 256 MB 總分: 100 可 Hack ✓

#8833. 均衡器埃尔曼特劳特

统计

当 Mike Ehrmantraut 开始当警察时,他希望法律面前人人平等。现在他退休了,但他仍然偏爱“几乎相等”的数组。

如果两个长度为 $n$ 的数组 $a$ 和 $b$ 满足以下条件,则称它们为“几乎相等”:

  • 对于任意 $1 \le i < j \le n$,都有 $\min(a_i, b_j) = \min(a_j, b_i)$。

给定两个整数 $n$ 和 $m$,求长度为 $n$ 且元素取值范围在 $1$ 到 $m$ 之间的整数数组对 $(a, b)$ 的数量。由于该数字可能很大,请输出其对 $998244353$ 取模的结果。

输入格式

输入仅一行,包含两个整数 $n, m$ ($1 \le n, m \le 10^6$)。

输出格式

输出一个整数,即该问题答案对 $998244353$ 取模的结果。

样例

样例输入 1

1 3

样例输出 1

9

样例输入 2

2 2

样例输出 2

10

样例输入 3

69 42

样例输出 3

608932821

说明

在第一个样例中,任何满足 $1 \le x, y \le 3$ 的数组对 $([x], [y])$ 都满足题目条件,共有 $9$ 种。

在第二个样例中,共有 $10$ 种数组对:$([1, 1], [1, 1]), ([1, 1], [1, 2]), ([1, 1], [2, 1]), ([1, 1], [2, 2]), ([1, 2], [1, 1]), ([1, 2], [1, 2]), ([2, 1], [1, 1]), ([2, 1], [2, 1]), ([2, 2], [1, 1]), ([2, 2], [2, 2])$。

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.