Time Limit: 2000/1000 MS (Java/Others)

Memory Limit: 32768/32768 K (Java/Others)

Number guessing is a popular game between elementary-school kids. Teachers encourage pupils to play the game as it enhances their arithmetic skills, logical thinking, and following-up simple procedures. We think that, most probably, you too will master in few minutes. Here’s one example of how you too can play this game: Ask a friend to think of a number, let’s call it n_{0}.

Then:

1. Ask your friend to compute n_{1} = 3 * n_{0} and to tell you if n1 is even or odd.

2. If n_{1} is even, ask your friend to compute n_{2} = n_{1}/2. If, otherwise, n_{1} was odd then let your friend compute n_{2} = (n_{1} + 1)/2.

3. Now ask your friend to calculate n_{3} = 3 * n_{2}.

4. Ask your friend to tell tell you the result of n_{4} = n_{3}/9. (n_{4} is the quotient of the division operation. In computer lingo, ’/’ is the integer-division operator.)

5. Now you can simply reveal the original number by calculating n_{0} = 2 * n_{4} if n_{1} was even, or n_{0} = 2 * n_{4} + 1 otherwise.

Here’s an example that you can follow: If n_{0} = 37, then n_{1} = 111 which is odd. Now we can calculate n_{2} = 56, n_{3}= 168, and n_{4} = 18, which is what your friend will tell you. Doing the calculation 2 × n_{4} + 1 = 37 reveals n_{0}.

Then:

1. Ask your friend to compute n

2. If n

3. Now ask your friend to calculate n

4. Ask your friend to tell tell you the result of n

5. Now you can simply reveal the original number by calculating n

Here’s an example that you can follow: If n

Your program will be tested on one or more test cases. Each test case is made of a single positive number (0 < n_{0} < 1, 000, 000).

The last line of the input file has a single zero (which is not part of the test cases.)

The last line of the input file has a single zero (which is not part of the test cases.)

提交代码