#16030. [ICPC 2020 Shanghai R] The Journey of Geor Autumn

    ID: 16030 传统题 1000ms 1024MiB 尝试: 0 已通过: 0 难度: (无) 上传者: 标签>P9823动态规划 DP2020上海O2优化组合数学逆元ICPC

[ICPC 2020 Shanghai R] The Journey of Geor Autumn

[ICPC 2020 Shanghai R] The Journey of Geor Autumn

题目描述

Once upon a time, there was a witch named Geor Autumn, who set off on a journey across the world. Along the way, she would meet all kinds of people, from a country full of ICPC competitors to a horse in love with dota---but with each meeting, Geor would become a small part of their story, and her own world would get a little bit bigger.

Geor just arrived at the state of Shu where people love poems. A poem is a permutation (a1,…,an)(a_1,\ldots, a_n) of [n][n]. ((a1,…,an)(a_1,\ldots, a_n) is a permutation of [n][n] means that each aia_i is an integer in [1,n][1,n] and that a1,…,ana_1,\ldots, a_n are distinct.) One poem is good\textit{good} if for all integer ii satisfying i>ki> k and i≤ni\le n, ai>min⁡(ai−k,…,ai−1)a_i>\min(a_{i-k}, \ldots, a_{i-1}). Here min⁡(ai−k,…,ai−1)\min(a_{i-k}, \ldots, a_{i-1}) denotes the minimum value among ai−k,…,ai−1a_{i-k}, \ldots, a_{i-1}.

Help Geor calculate how many good poems there are, given nn and kk. To avoid huge numbers, output the answer modulo 998244353998244353.

输入格式

The first line contains two integers $n$ and $k$ separated by a single space ($1\le n\le 10^7$, $1\le k\le 10^7$).

输出格式

Output only one integer in one line---the number of good poems modulo $998244353$.
1 1
1
2 3
2
3 2
4
4 2
10

提示

(暂无提示) 标签: P9823|动态规划 DP|2020|上海|O2优化|组合数学|逆元|ICPC

来源

P9823|[ICPC 2020 Shanghai R] The Journey of Geor Autumn