Time Limit: 1000 MS Memory Limit: 65536 K
A lame knight is located at the bottom-left corner of a n*m chessboard.
(n is the height and m is the width)
Unlike a healthy knight, a lame knight can only make moves where he goes to the right.
The only possible moves are:
1. 2 cells up, 1 cell right;
2. 1 cell up, 2 cells right;
3. 1 cell down, 2 cells right;
4. 2 cells down, 1 cell right.
The knight will make one trip, and he wants to maximize the number of visited cells.
The knight's starting cell counts toward this number. There is also one restriction
for the knight's trip: it must contain each kind of a move at least once, unless it
is shorter than 4 moves. If the knight makes less than 4 moves (thus visiting less
than 5 cells), his moves are not limited in any way. Return the maximal number of cells
the knight can visit during one trip, including the initial cell.
There are many test cases.For each case there is only one line contains two integers n and m.
( 1 <= n,m <= 10^9)
For each test case output the answer on a single line.
TopCoder SRM 380