#P8756. [蓝桥杯 2021 省 AB2] 国际象棋

[蓝桥杯 2021 省 AB2] 国际象棋

Problem Description

As everyone knows, the “Eight Queens” problem asks for the number of ways to place 88 queens on a chessboard so that no two queens attack each other. Xiao Lan, who has learned many algorithms, thinks the “Eight Queens” problem is too easy and still wants more. As a chess fan, he wants to study the following: on an N×MN \times M board, how many ways are there to place KK knights so that no two knights attack each other. Since the number of ways can be very large, you only need to compute the answer modulo 10000000071000000007 (i.e., 109+710^{9}+7).

As shown in the figure below, a knight in chess is placed inside a square and moves in an “L” shape. A knight located at square (x,y)(x, y) (row xx, column yy) can attack the 88 squares (x+1,y+2)(x+1, y+2), (x+1,y2)(x+1, y-2), (x1,y+2)(x-1, y+2), (x1,y2)(x-1, y-2), (x+2,y+1)(x+2, y+1), (x+2,y1)(x+2, y-1), (x2,y+1)(x-2, y+1), (x2,y1)(x-2, y-1).

Input Format

Input one line containing three positive integers NN, MM, and KK, representing the number of rows, the number of columns, and the number of knights.

Output Format

Output one integer, representing the number of valid placements modulo 10000000071000000007 (i.e., 109+710^{9}+7).

1 2 1
2
4 4 3
276
3 20 12
914051446

Hint

For 5%5\% of the testdata, K=1K=1.

For another 10%10\% of the testdata, K=2K=2.

For another 10%10\% of the testdata, N=1N=1.

For another 20%20\% of the testdata, N,M6N, M \leq 6, K5K \leq 5.

For another 25%25\% of the testdata, N3N \leq 3, M20M \leq 20, K12K \leq 12.

For all testdata, 1N61 \leq N \leq 6, 1M1001 \leq M \leq 100, 1K201 \leq K \leq 20.

Lanqiao Cup 2021 Second Round Provincial Contest, Group A Problem I (Group B Problem J).

Translated by ChatGPT 5