307343: CF1342E. Placing Rooks
Memory Limit:512 MB
Time Limit:2 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Placing Rooks
题意翻译
## 题目描述 $\mathsf E \color{red}\mathsf{ntropyIncreaser}$ 是国际象棋大师。 有这样一个问题: 在 $n \times n$ 的国际象棋棋盘上放 $n$ 个车,要求满足两个条件: - 所有的空格子都能被至少一个车攻击到。 - **恰好**有 $k$ 对车可以互相攻击到。 答案对 $998244353$ 取模。 $\mathsf E \color{red}\mathsf{ntropyIncreaser}$ 一眼就会了;但 NaCly\_Fish 太菜,并不会做,请你帮帮她吧。 ## 输入格式 输入一行两个整数 $n,k$。 ## 输出格式 输出一行一个整数,表示答案。 ## 数据范围 $1\le n \le 2\times 10^5$,$0 \le k \le \frac{n(n-1)}{2}$。题目描述
Calculate the number of ways to place $ n $ rooks on $ n \times n $ chessboard so that both following conditions are met: - each empty cell is under attack; - exactly $ k $ 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: ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF1342E/91e1a952e84863deabd2acee6b4796ec5e713ad0.png)One of the ways to place the rooks for $ n = 3 $ and $ k = 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 $ 998244353 $ .输入输出格式
输入格式
The only line of the input contains two integers $ n $ and $ k $ ( $ 1 \le n \le 200000 $ ; $ 0 \le k \le \frac{n(n - 1)}{2} $ ).
输出格式
Print one integer — the number of ways to place the rooks, taken modulo $ 998244353 $ .
输入输出样例
输入样例 #1
3 2
输出样例 #1
6
输入样例 #2
3 3
输出样例 #2
0
输入样例 #3
4 0
输出样例 #3
24
输入样例 #4
1337 42
输出样例 #4
807905441