Welcome to ZOJ
Select Problem
ZOJ Problem Set - 3576
Count the Length

Time Limit: 2 Seconds      Memory Limit: 65536 KB      Special Judge

You are given a board of m*n, so there are m*n unit squares(1*1) in the board. Suppose all unit squares are colored red or blue, and no adjacent(have common edge) unit squares share the same color. Consider the diagonal D of the board from left bottom to right top, D is a segment with color too, a point in D is red(or blue) if it falls in a red(or blue) unit square. Assume the left bottom square's color is red, then what is the total length of red part of the diagonal D?

the sample of 2 * 4 board
the total length of red part of the diagonal is 2.236068


There are multiple test cases(less than 10000). Each case is a line containing two integers m,n(1 ≤ m,n ≤ 2^31-1).


For each case, output a single line containing the right answer(rounded up to 3 digits after the decimal point).

Sample Input

2 4
1 3

Sample Output


Author: ZHANG, Debing
Contest: ZOJ Monthly, February 2012
Submit    Status