AT_arc228_e.Pair of Permutations

NOI/NOI+/CTSC

通过率:0%

时间限制:8.00s

内存限制:1024MB

AC君温馨提醒

该题目为【atcoder】题库的题目,您提交的代码将被提交至atcoder进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Find the number, modulo 998244353998244353, of pairs of permutations (P,Q)=((P1,P2,…,PN),(Q1,Q2,…,QN))(P,Q)=((P_1,P_2,\dots,P_N),(Q_1,Q_2,\dots,Q_N)) of (1,2,…,N)(1,2,\dots,N) satisfying the following condition.

  • Pi≤i+MP_i \le i+M, Qi≤i+MQ_i \le i+M, and Pi≠QiP_i \neq Q_i all hold for every integer ii satisfying 1≤i≤N1 \le i \le N.

求满足以下条件的排列对 (P,Q)=((P1,P2,…,PN),(Q1,Q2,…,QN))(P,Q)=((P_1,P_2,\dots,P_N),(Q_1,Q_2,\dots,Q_N))(其中 PP 和 QQ 均为 (1,2,…,N)(1,2,\dots,N) 的排列)的个数,结果对 998244353998244353 取模。

  • 对每个满足 1≤i≤N1 \le i \le N 的整数 ii,均有 Pi≤i+MP_i \le i+M、Qi≤i+MQ_i \le i+M 且 Pi≠QiP_i \neq Q_i。

输入格式

The input is given from Standard Input in the following format:

NN MM

输入从标准输入中以如下格式给出:

NN MM

输出格式

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)(P,Q) satisfying the condition are the following four pairs.

  • P=(1,2,3),Q=(2,3,1)P = (1,2,3),Q = (2,3,1)
  • P=(1,3,2),Q=(2,1,3)P = (1,3,2),Q = (2,1,3)
  • P=(2,3,1),Q=(1,2,3)P = (2,3,1),Q = (1,2,3)
  • P=(2,1,3),Q=(1,3,2)P = (2,1,3),Q = (1,3,2)

Constraints

  • 2≤N≤1092 \le N \le 10^9
  • 1≤M≤1250001 \le M \le 125000
  • All input values are integers.

样例 1 解释:
满足条件的数对 (P,Q)(P,Q) 共有以下四组:

  • P=(1,2,3), Q=(2,3,1)P = (1,2,3),\ Q = (2,3,1)
  • P=(1,3,2), Q=(2,1,3)P = (1,3,2),\ Q = (2,1,3)
  • P=(2,3,1), Q=(1,2,3)P = (2,3,1),\ Q = (1,2,3)
  • P=(2,1,3), Q=(1,3,2)P = (2,1,3),\ Q = (1,3,2)

限制条件

  • 2≤N≤1092 \le N \le 10^9
  • 1≤M≤1250001 \le M \le 125000
  • 所有输入值均为整数。

输入解题思路,AI测评打分。不知道怎么写?

首页