QOJ.ac

QOJ

حد الوقت: 1.0 s حد الذاكرة: 1024 MB مجموع النقاط: 100 قابلة للهجوم ✓

#8023. Geor Autumn 的旅程

الإحصائيات

从前,有一位名叫 Geor Autumn 的女巫,她踏上了环游世界的旅程。 在旅途中,她遇见了各种各样的人,从充满 ICPC 选手的国家到爱玩 Dota 的马——但每一次相遇,Geor 都会成为他们故事的一小部分,而她自己的世界也会变得更广阔一些。

Geor 刚刚抵达了热爱诗歌的蜀国。一首诗是一个 $[n]$ 的排列 $(a_1, \dots, a_n)$。($(a_1, \dots, a_n)$ 是 $[n]$ 的排列意味着每个 $a_i$ 都是 $[1, n]$ 中的整数,且 $a_1, \dots, a_n$ 各不相同。)如果对于所有满足 $i > k$ 且 $i \le n$ 的整数 $i$,都有 $a_i > \min(a_{i-k}, \dots, a_{i-1})$,则称这首诗是“好的”。这里 $\min(a_{i-k}, \dots, a_{i-1})$ 表示 $a_{i-k}, \dots, a_{i-1}$ 中的最小值。

请帮助 Geor 计算在给定 $n$ 和 $k$ 的情况下,有多少首好的诗。为了避免数字过大,请输出答案对 $998244353$ 取模的结果。

输入格式

第一行包含两个整数 $n$ 和 $k$,由单个空格分隔($1 \le n \le 10^7$,$1 \le k \le 10^7$)。

输出格式

仅输出一行一个整数——好的诗的数量对 $998244353$ 取模的结果。

样例

输入 1

1 1

输出 1

1

输入 2

2 3

输出 2

2

输入 3

3 2

输出 3

4

输入 4

4 2

输出 4

10

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.