1832: Lame Knight

内存限制:128 MB 时间限制:1.000 S
评测方式:文本比较 命题人:
提交:0 解决:0

题目描述

A lame knight is located at the bottom-left corner of a height x width chessboard. 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 several cases.Each case contains two numbers height(h) and width(w).Height will be between 1 and 2,000,000,000, inclusive. So is width.

输出

Output the maximal number of cells the knight can visit during one trip, including the initial cell. Per case per line.

样例输入 复制

100 50
1 1
17 5
2 4
20 4

样例输出 复制

48
1
4
2
4