AT_arc228_e.Pair of Permutations
NOI/NOI+/CTSC
通过率:0%
时间限制:8.00s
内存限制:1024MB
AC君温馨提醒
该题目为【atcoder】题库的题目,您提交的代码将被提交至atcoder进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Find the number, modulo 998244353, of pairs of permutations (P,Q)=((P1,P2,…,PN),(Q1,Q2,…,QN)) of (1,2,…,N) satisfying the following condition.
- Pi≤i+M, Qi≤i+M, and Pi=Qi all hold for every integer i satisfying 1≤i≤N.
求满足以下条件的排列对 (P,Q)=((P1,P2,…,PN),(Q1,Q2,…,QN))(其中 P 和 Q 均为 (1,2,…,N) 的排列)的个数,结果对 998244353 取模。
- 对每个满足 1≤i≤N 的整数 i,均有 Pi≤i+M、Qi≤i+M 且 Pi=Qi。
输入格式
The input is given from Standard Input in the following format:
N M
输入从标准输入中以如下格式给出:
N M
输出格式
Output the answer.
输出答案。
输入输出样例
输入#1
3 1
输出#1
4
输入#2
7 3
输出#2
644544
输入#3
1000000000 125000
输出#3
357543611
说明/提示
Sample 1 Explanation:
The pairs (P,Q) satisfying the condition are the following four pairs.
- P=(1,2,3),Q=(2,3,1)
- P=(1,3,2),Q=(2,1,3)
- P=(2,3,1),Q=(1,2,3)
- P=(2,1,3),Q=(1,3,2)
Constraints
- 2≤N≤109
- 1≤M≤125000
- All input values are integers.
样例 1 解释:
满足条件的数对 (P,Q) 共有以下四组:
- P=(1,2,3), Q=(2,3,1)
- P=(1,3,2), Q=(2,1,3)
- P=(2,3,1), Q=(1,2,3)
- P=(2,1,3), Q=(1,3,2)
限制条件
- 2≤N≤109
- 1≤M≤125000
- 所有输入值均为整数。
输入解题思路,AI测评打分。不知道怎么写?