Ensure that you are logged in and have the required permissions to access the test.

Game of Chocolates

4.4

27 votes
, Basic Math, C++, Math
Problem

Bunty and Bubly are good friends. Initially, Bunty has X chocolates and Bubly has Y chocolates. Now, they will play a game of chocolates and their turn will come alternatively. They will do the following in their turns starting with Bunty.

If the player has an odd number of chocolates, he will eat one of his chocolate, otherwise, he will do nothing. Then he will give half of his chocolate to his other friend. After K turns, find the number of chocolates that Bunty and Bubly have.

Input Format

The only line of input contains three integers - XYK

Output Format

Print two space-separated integers the number of chocolates that Bunty and Bubly have.

Constraint

1X,Y1091K105

 

Sample Input
5 4 2
Sample Output
5 3
Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation
  • Initially, Bunty has 5 and Bubly has 4 chocolates.
  • operation 1: Bunty eats one chocolate and then gives 2 chocolates to Bubly. They now have 2 and 6 chocolates, respectively.
  • operation 2: Bubly give 3 chocolates to Bunty. They now have 5 and 3 chocolates, respectively.
Editor Image

?