Game of Chocolates
Practice
4.4 (27 votes)
Basic math
C++
Math
Problem
86% Success 2644 Attempts 20 Points 1s Time Limit 256MB Memory 1024 KB Max Code
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 - \(X\), \(Y\), \(K\)
Output Format
Print two space-separated integers the number of chocolates that Bunty and Bubly have.
Constraint
\(1 \leq X, Y \leq 10^9 \\ 1 \leq K \leq 10^5\)
Submissions
Please login to view your submissions
Editorial