lightoj1010

maksyuki 发表于 oj 分类,标签:
0

1010 - Knights in Chessboard

Those who are not familiar with chess knights, note that a chess knight can attack 8 positions in the board as shown in the picture below.Given an m x n chessboard where you want to place chess knights. You have to find the number of maximum knights that can be placed in the chessboard such that no two knights attack each other.

Input

Input starts with an integer T (≤ 41000), denoting the number of test cases.

Each case contains two integers m, n (1 ≤ m, n ≤ 200). Here m and n corresponds to the number of rows and the number of columns of the board respectively.

Output

For each case, print the case number and maximum number of knights that can be placed in the board considering the above restrictions.

Sample Input

Output for Sample Input

38 83 74 10 Case 1: 32Case 2: 11Case 3: 20

 

题目类型:找规律

算法分析:维持row <= col,然后当row == 1时,直接输出col。当row == 2时,那么可以一次性把一个田字格全部放上马,然后间隔一个田字格,然后再放马。当row >= 3时,则直接判断棋盘上黑白格最大的那一个的个数即可(因为同一个颜色的格子中的马不会相互攻击)