CF1342E.Placing Rooks

提高+/省选-

通过率:0%

时间限制:2.00s

内存限制:512MB

AC君温馨提醒

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

题目描述

Calculate the number of ways to place nn rooks on n×nn \times n chessboard so that both following conditions are met:

  • each empty cell is under attack;
  • exactly kk pairs of rooks attack each other.

An empty cell is under attack if there is at least one rook in the same row or at least one rook in the same column. Two rooks attack each other if they share the same row or column, and there are no other rooks between them. For example, there are only two pairs of rooks that attack each other in the following picture:

One of the ways to place the rooks for n=3n = 3 and k=2k = 2

Two ways to place the rooks are considered different if there exists at least one cell which is empty in one of the ways but contains a rook in another way.

The answer might be large, so print it modulo 998244353998244353.

计算在 n×nn \times n 棋盘上放置 nn 个车(rook)的方案数,使得同时满足以下两个条件:

  • 每个空格均被攻击;
  • 恰好有 kk 对车相互攻击。

一个空格被攻击,当且仅当其所在行或所在列中至少存在一个车。两个车相互攻击,当且仅当它们位于同一行或同一列,且二者之间(沿该行或该列方向)不存在其他车。例如,在下图中仅有两对车相互攻击:

当 n=3n = 3、k=2k = 2 时的一种合法放法

若存在某个格子,在一种放法中为空、而在另一种放法中放置了车,则认为这两种放法不同。

答案可能很大,请对 998244353998244353 取模后输出。

输入格式

The only line of the input contains two integers nn and kk (1≤n≤2000001 \le n \le 200000; 0≤k≤n(n−1)20 \le k \le \frac{n(n - 1)}{2}).

输入仅包含一行,其中有两个整数 nn 和 kk(1≤n≤2000001 \le n \le 200000;0≤k≤n(n−1)20 \le k \le \frac{n(n - 1)}{2})。

输出格式

Print one integer — the number of ways to place the rooks, taken modulo 998244353998244353.

输出一个整数——放置车的方法数,对 998244353998244353 取模。

输入输出样例

  • 输入#1

    3 2

    输出#1

    6
  • 输入#2

    3 3

    输出#2

    0
  • 输入#3

    4 0

    输出#3

    24
  • 输入#4

    1337 42

    输出#4

    807905441

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

首页