原题题面
Calculate the number of ways to place n rooks on n×n chessboard so that both following conditions are met:
each empty cell is under attack;
exactly k k 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:
One of the ways to place the rooks for n = 3 n=3 n=3 and k = 2 k=2 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 998244353 998244353.
输入格式
The only line of the input contains two integers n n n and k k k ( 1 ≤ n ≤ 200000 1\leq n\leq 200000 1≤n≤200000; 0 ≤ k ≤ n ( n − 1 ) 2 0\leq k\leq \frac{n(n−1)}{2} 0≤k≤2n(n−1)).
输出格式
Print one integer — the number of ways to place the rooks, taken modulo 998244353 998244353 998244353.
输入样例
1337 42
输出样例
807905441
题面分析
考虑到至少每个行或每个列都要有棋子,每行或每列都有一个棋子,那假设每一行都有棋子,再把答案乘2即可。
稍加推导可知,如果有 k k k个棋子属于相互攻击的状态,那么它们应该占据了 n − k n-k n−k列,证明略。
由此可知,如果所有的棋子都能排成一列,那此时存在 n − 1 n-1 n−