Rikka with Chess
Time limit:2000/1000 MS (java/others) Memory limit:65536/65536 K (java/others)
Total submission (s): 177 Accepted Submission (s): 161
Problem Descriptionyuta gives Rikka a chess board of sizenxm.
As we all know, on a chess board, every cell was either black or white and every and the cells that share a side had different Colors.
Rikka can choose any rectangle formed by board squares and perform a inversion, every white cell becomes black, and vice Versa.
Rikka wants to turn all cells into the same color, please tell Rikka the minimal number of inversions she need to achieve Her goal.
Inputthe First line contains a numberT(t≤ten) --the number of the testcases.
Each testcase contains and numbersn,m(n≤9,m≤9) .
Outputfor each testcase, print a single number which represents the answer.
Sample Input31 22 23 3
Sample Output122 Test instructions: to a n*m black-and-white rectangle, each time you can choose an arbitrarily long rectangle from the rectangle, the grid in which the inverse color, ask the minimum number of actions to make all the lattice color the same puzzle: Draw a graph can be found in the law between the two lines between the color of the grid is just reversed color, So we will be any line invert color can make two rows up and down lattice same color, so we operate the M/2 times, Operation finished, each column of the grid is the same color but adjacent to the two columns invert color at this time we will inverse color of the lattice inversion colors can be N/2, so the answer is N/2+M/2
Bestcoder Round #73 (Div.2) (Hdu 5630)