atcoder#TENKA12018B. Exchange

Exchange

Score : 200200 points

Problem Statement

In the beginning, Takahashi has AA cookies, and Aoki has BB cookies. They will perform the following operation alternately, starting from Takahashi:

  • If the number of cookies in his hand is odd, eat one of those cookies; if the number is even, do nothing. Then, give one-half of the cookies in his hand to the other person.

Find the numbers of cookies Takahashi and Aoki respectively have after performing KK operations in total.

Constraints

  • 1A,B1091 \leq A,B \leq 10^9
  • 1K1001 \leq K \leq 100
  • A,BA,B and KK are integers.

Input

Input is given from Standard Input in the following format:

AA BB KK

Output

Print the number of cookies Takahashi has, and the number of cookies Aoki has, in this order, after performing KK operations in total.

5 4 2
5 3

The process will go as follows:

  • In the beginning, Takahashi and Aoki have 55 and 44 cookies, respectively.
  • Takahashi eats one cookie and gives two cookies to Aoki. They now have 22 and 66 cookies, respectively.
  • Aoki gives three cookies to Takahashi. They now have 55 and 33 cookies, respectively.
3 3 3
1 3
314159265 358979323 84
448759046 224379523