The Black and White Knights
How many ways are there to place a black and a white knight on an N * M chessboard such that they do not attack each other? The knights have to be placed on different squares. A knight can move two squares horizontally and one square vertically, or two squares vertically and one square horizontally. The knights attack each other if one can reach the other in one move.
Input :
The first line contains the number of test cases T. Each of the next T lines contains two integers N and M.
Output :
Maximal crosses
The 'Clarification' in the problem statement has been updated on July 2nd at 6:15pm
On the matrix A sized n n, some cells were marked by crosses (X). For each cell (i,j) (with i the row index, j the column index), we define B(i,j) as the maximal number of continuous crosses going across the cell (i,j) in the same horizontal, vertical or diagonal; B(i,j)=0 if A(i,j) is empty ( '.' ). [ Empty cells are marked by '.'] .
| ‹ previous | 23 of 33 | next › |