#3575. Rook Path
0
Rook Path
Rook Path
题目描述
There is a -square grid with horizontal rows and vertical columns. Let denote the square at the -th row from the top and -th column from the left.
The grid has a rook, initially on . Takahashi will do the following operation times.
将车移动到与当前占据的格子同一行或同一列的某个格子。这里,必须移动到与当前格子不同的格子。
有多少种方法进行这 次操作,使得最后车会在 ?由于答案可能非常大,请对 取模。
输入格式
Input is given from Standard Input in the following format:
输出格式
Print the number of ways to do the operations so that the rook will be on in the end, modulo .
2 2 2
1 2 2 1
2
1000000000 1000000000 1000000
1000000000 1000000000 1000000000 1000000000
24922282
3 3 3
1 3 3 3
9
提示
We have the following two ways.
First, move the rook from to . Second, move it from to .
First, move the rook from to . Second, move it from to .
Be sure to find the count modulo .
标签: AtCoder|abc232E
来源
AtCoder|abc232E