QOJ.ac

QOJ

حد الوقت: 3 s حد الذاكرة: 512 MB مجموع النقاط: 100

#4604. 沙塔斯城

الإحصائيات

–“为什么一位‘先知’不预警灾难?” –“你为什么不向世界预警大灾变?”凡人孩童简单而合乎逻辑的质问在寂静的密室中回荡,带着指责的意味,打断了先知对圣光的沉思。维伦选择了回避而非回答,选择了遮掩而非阐明。他对自己感到惊讶。我还能欺骗吗?即使在经历了这么久之后?无论是内心还是外在? –维伦正陷入自我怀疑之中。

维伦称一个序列为“$n$-优美”的,如果它满足以下三个条件: 1. 它的长度大于 $n$。 2. 序列中的每个元素都是不超过 $n$ 的正整数。 3. 它的每一个长度为 $n$ 的连续子序列都不是 $1, 2, \dots, n$ 的一个排列。

维伦从“$n$-优美”序列中获得了灵感,因此他想知道长度为 $m$ 的“$n$-优美”序列的数量。 你能帮帮他吗? 由于答案可能非常大,你只需要输出答案对 $998244353$ 取模后的结果。

输入格式

本题包含多组测试数据。 第一行包含一个整数 $T(1 \le T \le 4)$,表示测试数据的组数。 每个测试用例仅包含一行,包含两个整数 $n, m (3 \le n < m \le 2 \times 10^5)$。

输出格式

对于每组测试数据,输出一行,包含一个整数,表示答案。

样例

样例输入 1

3
3 5
5 10
100000 200000

样例输出 1

123
8001745
700646201

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.