QOJ.ac

QOJ

Time Limit: 5.0 s Memory Limit: 1024 MB Total points: 100

#4822. Matrix Counting

Statistics

如果一个 $n \times n$ 的矩阵仅包含 0 和 1,且每一行和每一列都恰好包含一个 1,则称该矩阵为“坏的”(bad)。

定义 $B$ 为 $n \times n$ 矩阵 $A$ 的子矩形,当且仅当存在 $1 \le l_1 \le r_1 \le n$ 和 $1 \le l_2 \le r_2 \le n$ 使得: $B$ 是一个 $(r_1 - l_1 + 1) \times (r_2 - l_2 + 1)$ 的矩阵。 $B_{i,j} = A_{l_1+i-1, r_1+j-1}$ (其中 $1 \le i \le r_1 - l_1 + 1, 1 \le j \le r_2 - l_2 + 1$)。

给定两个整数 $n$ 和 $m$,你需要计算有多少个仅包含 0 和 1 的 $n \times n$ 矩阵 $M$ 满足: 1. $M$ 是坏的, 2. 它所有大小为 $k \times k$ 的子矩形($k = m + 1, m + 2, \dots, n - 1$)都不是坏的。

由于答案可能很大,请输出其对 $998\,244\,353$ 取模的结果。

输入格式

第一行包含两个整数 $n$ 和 $m$($1 \le m < n \le 10^5$)。

输出格式

输出一行,包含一个整数,表示答案对 $998\,244\,353$ 取模的结果。

样例

输入 1

3 2

输出 1

6

输入 2

4 2

输出 2

4

输入 3

300 20

输出 3

368258992

输入 4

100000 1

输出 4

91844344

说明

在第一个样例中,共有 6 个坏矩阵。第二个条件不产生影响,因为 $m + 1 = 3 > n - 1 = 2$。因此答案为 6。

在第二个样例中,有 4 个矩阵满足条件:

$$ \begin{bmatrix} 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 1 \\ 1 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 \end{bmatrix} \quad \begin{bmatrix} 0 & 0 & 1 & 0 \\ 1 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 \\ 0 & 1 & 0 & 0 \end{bmatrix} \quad \begin{bmatrix} 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 1 \\ 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \end{bmatrix} \quad \begin{bmatrix} 0 & 1 & 0 & 0 \\ 1 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 \\ 0 & 0 & 1 & 0 \end{bmatrix} $$

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.