P27030 [AtCoder] Exchange
入门
题目描述

Problem Description

Takahashi initially has $ A $ cookies, and Aoki initially has $ B $ cookies. They repeat the following operation alternately, starting from Takahashi:

  • If the number of cookies one has is odd, they eat one cookie; if even, they do nothing. Then, they give half of their cookies to the other person.

After a total of $ K $ operations, find the number of cookies Takahashi and Aoki have, respectively.

Input Format

The input is given from the standard input in the following format:

$ A $ $ B $ $ K $

Output Format

Output the number of cookies Takahashi and Aoki have after a total of $ K $ operations, in that order.

Sample Input and Output

Sample Input #1

5 4 2

Sample Output #1

5 3

Sample Input #2

3 3 3

Sample Output #2

1 3

Sample Input #3

314159265 358979323 84

Sample Output #3

448759046 224379523

Notes/Hints

Constraints

  • $1 \leq A, B \leq 10^9$
  • $1 \leq K \leq 100$
  • $ A, B, K $ are integers

Sample Explanation 1

The operations proceed as follows:
- Initially, Takahashi and Aoki have $ 5, 4 $ cookies, respectively.
- Takahashi eats one cookie and gives $ 2 $ cookies to Aoki. After the operation, they have $ 2, 6 $ cookies, respectively.
- Aoki gives $ 3 $ cookies to Takahashi. They have $ 5, 3 $ cookies, respectively.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
5 4 2
样例输出
5 3