atcoder#TENKA12018B. Exchange
Exchange
Score : points
Problem Statement
In the beginning, Takahashi has cookies, and Aoki has 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 operations in total.
Constraints
- and are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the number of cookies Takahashi has, and the number of cookies Aoki has, in this order, after performing operations in total.
5 4 2
5 3
The process will go as follows:
- In the beginning, Takahashi and Aoki have and cookies, respectively.
- Takahashi eats one cookie and gives two cookies to Aoki. They now have and cookies, respectively.
- Aoki gives three cookies to Takahashi. They now have and cookies, respectively.
3 3 3
1 3
314159265 358979323 84
448759046 224379523