2127. Paper Cutting

单点时限: 2.0 sec

内存限制: 256 MB

You are given a paper of dimension mn, and you have to cut into mn squares each of dimension 11 using a scissors. What is the minimum number of cuts needs to get all mn squares?

输入格式

Input consists of several test cases. Each case appears on a single line, and there is no blank line between two cases. Each line has two numbers m and n, indicating the dimension of the paper. The input is terminated by the case m=0 and n=0. You do not have to handle this case. Both m and n will fit in a 32-bit integer representation.

输出格式

For each input, output the minimum number of cuts needed, as specified above.

样例

Input
2 2
1 1
5 1
0 0
Output
3
0
4

34 人解决,77 人已尝试。

37 份提交通过,共有 121 份提交。

5.6 EMB 奖励。

创建: 12 年,5 月前.

修改: 3 年,2 月前.

最后提交: 8 月,3 周前.

来源: Codewars 2006

题目标签