Problem:


Score : 200 points

Problem Statement

In the beginning, Takahashi has A cookies, and Aoki has B 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 K operations in total.

Constraints

1 \leq A,B \leq 10^9

1 \leq K \leq 100

A,B and K are integers.

Input

Input is given from Standard Input in the following format:

A B K

Output

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

Sample Input 1

5 4 2

Sample Output 1

5 3

The process will go as follows:

In the beginning, Takahashi and Aoki have 5 and 4 cookies, respectively.

Takahashi eats one cookie and gives two cookies to Aoki. They now have 2 and 6 cookies, respectively.

Aoki gives three cookies to Takahashi. They now have 5 and 3 cookies, respectively.

Sample Input 2

3 3 3

Sample Output 2

1 3

Sample Input 3

314159265 358979323 84

Sample Output 3

448759046 224379523



Sample input:
5 4 2


Sample output:
5 3

Submission status: Wrong Answer

Solution code:
a, b, K = map(int, input().split())
for k in range(int(K / 2)):
    if a % 2 == 1:
        a -= 1
    b += a / 2
    a -= a / 2
    if b % 2 == 1:
        b -= 1
    a += b / 2
    b -= b / 2
print(int(a), int(b))

Submission status: Wrong Answer

Solution code:
a,b,c=map(int,input().split())
if c%2==0:
    for _ in range(int(c/2)):
        if a %2 == 0:
            d=0
        else:
            a=(a-1)
        a=a/2
        b=a + b
        if b%2== 0:
            d=0
        else:
                b=(b-1)
        b=b/2
        a+=b
    print(int(a),int(b))



else:
    if c%2==1:
        for _ in range(int(c/2)):
            if a %2 == 0:
                d=0
            else:
                a=(a-1)
            a=a/2
            b=a + b
            if b%2== 0:
                d=0
            else:
                b=(b-1)
            b=b/2
            a+=b
        
        if a %2 == 0:
            d=0
        else:
            a=(a-1)
            a=a/2
            b=a + b
        print(int(a),int(b))

Submission status: Wrong Answer

Solution code:
A, B, K = map(int, input().split())

for k in range(K):

    if A % 2 != 0:
        
        if A != 0:
            
            A -= 1

    B += round(A/2)
    A -= round(A/2)

    if B % 2 != 0:

        if B != 0:
            
            B -= 1


    A += round(B/2)
    B -= round(B/2)

print(A, B)

Submission status: Wrong Answer

Solution code:
#coding:utf-8

A, B, K = map(int, input().split())

is_odd = K % 2

for k in range(K):
    if k % 2 == is_odd:
        if A % 2 == 1:
            A -= 1
        B = B + A * 0.5
        A = A * 0.5

    else:
        if B % 2 == 1:
            B -= 1
        A = A + B * 0.5
        B = B * 0.5

print(int(A), int(B))

Submission status: Wrong Answer

Solution code:
a = list(map(int,input().split()))

A = a[0]; B = a[1]; K = a[2]

for i in range(K):
    if i % 2 == 0:
        if A % 2 == 1:
            A -= 1
        cokkie = A / 2
        A -= cokkie
        B += cokkie
    else:
        if B % 2 == 1:
            B -= 1
        cokkie = B / 2
        B -= cokkie
        A += cokkie

print(str(A) + " " + str(B))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

# 入力値受け取り
A, B, K = map(int, input().split())
print(A, B, K)

for i in range(K):
    if i % 2 == 0:
        # A を操作
        if A % 2 != 0:
            A -= 1
        A //= 2
        B += A
    else:
        # B を操作
        if B % 2 != 0:
            B -= 1
        B //= 2
        A += B

# 結果出力
print("{} {}".format(A, B))

Submission status: Wrong Answer

Solution code:
A,B,K = map(int,input().split())

countK = 0
while(countK<K):
    if countK%2 == 0:
        if A%2 == 1:
            A -= 1
            A = A//2
            B = B + A
        else:
            A = A//2
            B = B + A//2
    else:
        if B%2 == 1:
            B -= 1
            B = B//2
            A = A + B//2
        else:
            B = B//2
            A = A + B
    countK += 1
print("{} {}".format(A,B))

Submission status: Wrong Answer

Solution code:
a, b, k =  map(int, input().split())
turn_a = 1
for i in range(k):
  if turn_a == 1:
    if a % 2 == 1:
      b = b + (a-1)/2
      a = (a-1)/2
    else:
      b = b + a/2
      a = a/2
    turn_a = 0
  else:
    if b % 2 == 1:
      a = a + (b-1)/2
      b = (b-1)/2      
    else:
      a = a + b/2
      b = b/2 
    turn_a = 1
print(a, b)

Submission status: Wrong Answer

Solution code:
a, b, c = input().split()

a = int(a)
b = int(b)
c = int(c)

for i in range(c):
    if (a%2 == 1):
        a = a-1
    if (b%2 == 1):
        b = b - 1
    ac = a
    bc = b
    if(i%2 == 0):
        a = a/2 
        b = b + ac/2
    else:
        a = a+bc/2
        b = b/2 

print(int(a), int(b))

Submission status: Wrong Answer

Solution code:
A, B, K = map(int, input().split())

for k in range(K):

    if A % 2 != 0:
        
        A -= 1

    B += round(A/2)
    A -= round(A/2)

    if B % 2 != 0:

        B -= 1

    A += round(B/2)
    B -= round(B/2)

print(A, B)

Submission status: Wrong Answer

Solution code:
a, b, k = map(int, input().split())
for i in range(k):
    if i%2 == 0:
        if a%2 == 0:
            a /= 2
            b += a
        elif a%2 == 1:
            a -= 1
            a /= 2
            b += a
    elif i%2 == 1:
        if b%2 == 0:
            b /= 2
            a += b
        elif a%2 == 1:
            b -= 1
            b /= 2
            a += b
print(int(a),int(b))

Submission status: Wrong Answer

Solution code:
a, b, k = [int(i) for i in input().split(" ")]

for i in range(k):
  if a % 2 == 1:
    a -= 1

  b += (a / 2)
  a = a / 2

  if b % 2 == 1:
    b -= 1

  a += (b / 2)
  b = b / 2

print("{} {}".format(int(a), int(b)))

Submission status: Wrong Answer

Solution code:
a, b, k = map(int, input().split())
for i in range(k):
    if i%2 == 0:
        if a%2 == 0:
            a /= 2
            b += 2
        elif a%2 == 1:
            a -= 1
            a /= 2
            b += a
    elif i%2 == 1:
        if b%2 == 0:
            b /= 2
            a += b
        elif a%2 == 1:
            b -= 1
            b /= 2
            a += 2
print(int(a),int(b))

Submission status: Wrong Answer

Solution code:
A, B, K = map(int, input().split())

for i in range(K):
    if (A == 0 or B == 0):
        break
    if A % 2 == 1:
        A -= 1
    A /= 2
    A, B = B + A, A

print(int(A), int(B))

Submission status: Wrong Answer

Solution code:
a, b, k = map(int, input().split())
for i in range(k):
    if i%2 == 0:
        if a%2 == 0:
            a /= 2
            b += 2
        elif a%2 == 1:
            a -= 1
            a /= 2
            b += a
    elif i%2 == 1:
        if b%2 == 0:
            b /= 2
            a += b
        elif a%2 == 1:
            b -= 1
            b /= 2
            a += 2
    print(int(a),int(b))
print(int(a),int(b))

Submission status: Wrong Answer

Solution code:
a, b, k = map(int, input().split())
for i in range(k):
    if i % 2 == 0:
        if a % 2 == 1:
            a -= 1
        b += a / 2
        a /= 2
        
    else:
        if b % 2 == 1:
            b -= 1
        a += b / 2
        b /= 2
print(a, b)

Submission status: Wrong Answer

Solution code:
A, B, K = map(int, input().split())

for k in range(K):

    if A % 2 != 0:
        
        A -= 1

    B += A/2
    A -= A/2

    if B % 2!= 0:

        B -= 1

    A += B/2
    B -= B/2

print(round(A), round(B))

Submission status: Wrong Answer

Solution code:
A, B, K = map(int, input().split())

for i in range(K):
    if A % 2 == 1:
        A -= 1
    A /= 2
    A, B = B + A, A

print(int(A), int(B))

Submission status: Wrong Answer

Solution code:
A, B, K = map(int, input().strip().split())

for k in range(K):
  if k % 2 == 0:
    A = A // 2
    B = B + A // 2
  else:
    B = B // 2
    A = A + B // 2
    
print(A, B)

Submission status: Wrong Answer

Solution code:
a,b,k=map(int,input().split())
t=True
for i in range(0,k):
    if t==True:
        a=a//2
        b+=a
    else:
        b=b//2
        a+=b
    t=not t

Submission status: Wrong Answer

Solution code:
a,b,k = map(int,input().split())

for i in range(k):
    if i % 2 == 0:
        if a % 2 == 1:
            a -= 1
        
        b += a / 2
        a /= 2
    else:
        if b % 2 == 1:
            b -= 1

        a += b / 2
        b /= 2


print(a,b)

Submission status: Wrong Answer

Solution code:
a,b,k = map(int,input().split())
c = 0
while k>0:
    if c == 0:
        a -= a%2
        a,b = a//2,b+a//2
    else:
        b -= a%2
        b,a = b//2,a+b//2
    c = 1-c    
    k -= 1
print(a,b)

Submission status: Wrong Answer

Solution code:
a, b, k = map(int, input().split(' '))

for i in range(k):

    if i % 2 == 0:
        if a % 2 == 1:
            a -= 1
        
        tmp_a = int(a / 2)

        a = tmp_a
        b = b + tmp_a

    else:
        if b % 2 == 1:
            b -= 1
        
        tmp_b = int(b / 2)

        b = tmp_b
        a = a + tmp_b

Submission status: Time Limit Exceeded

Solution code:
A, B, K = map(int, input().split())
c = 0
while True:
    if A % 2 == 0:
        pass
    else:
        A -= 1

    B += A / 2
    A -= A / 2
    c += 1

    if B % 2 == 0:
        pass
    else:
        B -= 1

    A += B / 2
    B -= B / 2
    c += 1

    if c == K:
        break

print(int(A), int(B))

Submission status: Accepted

Solution code:
A, B, K = map(int,input().split())
for i in range(K):
  if i % 2 == 0:
    A = A // 2
    B += A
  else:
    B = B // 2
    A += B
print(int(A), int(B))

Submission status: Accepted

Solution code:
a, b, k = map(int, input().split())

flag = True
for i in range(k):
    if flag:
        if a % 2 == 1:
            a -= 1
        b += a // 2
        a = a // 2
        flag = False
    else:
        if b % 2 == 1:
            b -= 1
        a += b // 2
        b = b // 2
        flag = True
print(a, b)

Submission status: Accepted

Solution code:
A, B, K = map(int, input().split())
f = 0
for i in range(K):
  if f == 0:
    A, B = A // 2, B + A // 2
  else:
    A, B = A + B // 2, B // 2
  f ^= 1
print(str(A) + " " + str(B))

Submission status: Accepted

Solution code:
A,B,K = (int(T) for T in input().split())
for TK in range(0,K):
    if TK%2==0:
        A -= [0,1][A%2]
        Give = A//2
        A,B  = A-Give,B+Give
    else:
        B -= [0,1][B%2]
        Give = B//2
        A,B  = A+Give,B-Give 
print('{} {}'.format(A,B))

Submission status: Accepted

Solution code:
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
a, b, k = M()
for i in range(k):
    if i % 2 == 0:
        # 高橋くんの場合
        if a % 2 == 1:
            a -= 1
        b = b + a//2
        a = a//2
    else:
        if b % 2 == 1:
            b -= 1
        a = a + b//2
        b = b//2
print(a, b)

Submission status: Accepted

Solution code:
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from math import gcd
from itertools import combinations,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
import math
import bisect
import heapq
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入g
#
# インデックス系
# int min_y = max(0, i - 2), max_y = min(h - 1, i + 2);
# int min_x = max(0, j - 2), max_x = min(w - 1, j + 2);
#
#
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
#mod = 998244353
INF = float('inf')
from sys import stdin
readline = stdin.readline
def readInts():
  return list(map(int,readline().split()))
def readTuples():
    return tuple(map(int,readline().split()))
def I():
    return int(readline())
a,b,k = readInts()
cnt = 0
while cnt < k:
    if cnt%2 == 0:
        a //= 2
        b += a
    else:
        b //= 2
        a += b
    cnt += 1
print(a,b)

Submission status: Accepted

Solution code:
a,b,k=map(int,input().split())
for i in range(k):
    if i %2==0:
        b+=a//2
        a//=2
    else:
        a += b // 2
        b //= 2
print(a,b)

Submission status: Accepted

Solution code:
a,b,k=map(int,input().split())
cnt=k
while(k>0):
    if a %2==1:
        a-=1
        b+=a//2
        a//=2
        cnt-=1
        # print(a,b,k)
    else:
        b += a // 2
        a//=2
        cnt -= 1

    if cnt==0:
        print(a,b)
        break
    if b %2==1:
            b -= 1
            a += b // 2
            b//=2
            cnt -= 1
            # print(a,b,k)
    else:
        a += b // 2
        b//=2
        cnt -= 1

    if cnt==0:
        print(a,b)
        break

Submission status: Accepted

Solution code:
a, b, k = list(map(int, input().split()))
for i in range(k):
    if i % 2 == 0:
        if a % 2 == 1:
            a -= 1
        tmp_a = a//2
        a -= tmp_a
        b += tmp_a
    if i % 2 == 1:
        if b % 2 == 1:
            b -= 1
        tmp_b = b//2
        b -= tmp_b
        a += tmp_b

print(a, b)

Submission status: Accepted

Solution code:
A, B, K = map(int, input().split())
for i in range(K):
    if i%2==0:
        A //= 2
        B += A
    else:
        B //= 2
        A += B

print(A, B)

Submission status: Accepted

Solution code:
a,b,k = map(int,input().split())
for i in range(k):
    if i%2==0:
        if a%2==1:
            a-=1
        c =a//2
        b+=c
        a-=c
    else:
        if b%2==1:
            b-=1
        c =b//2
        a+=c
        b-=c
print(a,b)

Submission status: Accepted

Solution code:
from sys import stdin
rs = lambda : stdin.readline().strip()
ri = lambda : int(rs())
ril = lambda : list(map(int, rs().split()))

def main():
    a, b, k = ril()
    t = True
    for i in range(k):
        if t:
            if a % 2 == 1:
                a -= 1
            b += a // 2
            a //= 2
        else:
            if b % 2 == 1:
                b -= 1
            a += b // 2
            b //= 2
        t = not t
    print(a, b)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
a,b,k=map(int,input().split())

for i in range(1,k+1):
    if i%2:
        if a%2:
            a-=1
        a//=2
        b+=a
    else:
        if b%2:
            b-=1
        b//=2
        a+=b

print(a,b)

Submission status: Accepted

Solution code:
a, b, k = map(int, input().split())

for i in range(k):
    if i % 2 == 0:
        if a % 2 == 1:
            a -= 1
        exchenge = a // 2
        a -= exchenge
        b += exchenge 
    if i % 2 == 1:
        if b % 2 == 1:
            b -= 1
        exchenge = b // 2
        b -= exchenge
        a += exchenge   
print(f'{a} {b}')

Submission status: Accepted

Solution code:
a, b, k = map(int, input().split())
for i in range(k):
    if i % 2 == 0:
        a = a // 2
        b += a
    else:
        b = b // 2
        a += b
print(a, b)

Submission status: Accepted

Solution code:
A,B,K=map(int,input().split())
cnt=0
while True:
    if A % 2 == 1:
        A -= 1
    B += A // 2
    A //= 2
    cnt += 1
    if cnt >= K:
        break
    if B % 2 == 1:
        B -= 1
    A += B // 2
    B //= 2
    cnt += 1
    if cnt >= K:
        break
print('{} {}'.format(A,B))

Submission status: Accepted

Solution code:
A,B,K=map(int,input().split())


k=0
for i in range(100):
    if A%2==1:
        A-=1
    B=B+A//2
    A=A-A//2
    k+=1
    if k== K:
        print(A,B)
        break
    if B%2==1:
        B-=1
    A=A+B//2
    B=B-B//2
    k+=1
    if k== K:
        print(A,B)
        break

Submission status: Accepted

Solution code:
A, B, K = map(int, input().split())

for i in range(K):
    if i % 2 == 0:
        if A & 1:
            A -= 1
        B += A // 2
        A //= 2
    else:
        if B & 1:
            B -= 1
        A += B // 2
        B //= 2
    # print(i, A, B)
print(A, B)

Submission status: Accepted

Solution code:
A,B,K=map(int,input().split())

for i in range(K):
  if i%2:
    if B%2:
      B -= 1
    A,B = A+B//2,B//2
  else:
    if A%2:
      A -= 1
    A,B = A//2,B+A//2
    
print(A,B)

Submission status: Accepted

Solution code:
a,b,k = map(int,input().split())

i = 1
while i <=k:
    if i%2 == 1:
        if a%2 == 1:
            a -=1
            a //=2
            b +=a
        else:
            a //=2
            b +=a

    else:
        if b%2 == 1:
            b -=1
            b //=2
            a +=b
        else:
            b //=2
            a +=b

    i +=1

print(a,b)

Submission status: Accepted

Solution code:
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    A, B, K = map(int, readline().split())

    for i in range(K):
        if i % 2 == 0:
            if A % 2 == 1:
                A -= 1
            B += A // 2
            A //= 2
        else:
            if B % 2 == 1:
                B -= 1
            A += B // 2
            B //= 2
    print(A, B)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def main():
    a, b, k = map(int, input().split())

    for i in range(k):
        if i % 2 == 0:
            if a % 2 == 1:
                a -= 1
            b += a // 2
            a //= 2
        else:
            if b % 2 == 1:
                b -= 1
            a += b // 2
            b //= 2

    print(a, b)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def solve():
    A, B, K = map(int, input().split())

    while K > 0:
        if A % 2 == 1:
            A -= 1

        A //= 2
        B += A
        K -= 1

        if K == 0:
            break

        if B % 2 == 1:
            B -= 1

        B //= 2
        A += B
        K -= 1

    print(A, B)


def main():
    solve()


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# Tenka1 Programmer Beginner Contest 2018: B – Exchange
A, B, K = [int(i) for i in input().split()]

for i in range(1, K + 1):
    if i % 2 == 1:
        A = (A - 1) // 2 if A % 2 == 1 else A // 2
        B += A
    else:
        B = (B - 1) // 2 if B % 2 == 1 else B // 2
        A += B

print(A, B)

Submission status: Accepted

Solution code:
A, B, K = map(int, input().split())
c = [A, B]
for i in range(K):
    if c[i%2]%2 == 1:
        c[i%2] -= 1
    c[(i+1)%2] += c[i%2]//2
    c[i%2] //= 2
print(*c)

Submission status: Accepted

Solution code:
A,B,K=map(int,input().split())

for i in range(K):
    if not i%2:
        A=A-A%2
        A,B=A//2,B+A//2
    else:
        B=B-B%2
        A,B=A+B//2,B//2
print(A,B)

Submission status: Accepted

Solution code:
# B - Exchange
A,B,K = map(int,input().split())
for i in range(K):
    if i%2==0:
        A = A-A%2
        A,B = A//2,B+A//2
    else:
        B = B-B%2
        A,B = A+B//2,B//2
print(A,B)

Submission status: Accepted

Solution code:
a, b, k = map(int, input().split())
for i in range(k):
    if i % 2 == 0:
        if a % 2 == 1:
            a -= 1
        a, b = a // 2, b+a//2
    else:
        if b % 2 == 1:
            b -= 1
        a, b = a+b//2, b//2
print(a, b)

Submission status: Accepted

Solution code:
A,B,K = map(int,input().split())
for i in range(K):
  if i%2 == 0:
    if A%2 == 1:
      A -=1
      X = A/2
      A -= X
      B += X
    else:
      X = A/2
      A -= X
      B += X
  else:
    if B%2 == 1:
      B -=1
      X = B/2
      B -= X
      A += X
    else:
      X = B/2
      B -= X
      A += X
print(int(A),int(B))

Submission status: Accepted

Solution code:
a,b,k = map(int,input().split())
for i in range(k):
    if i%2 == 0:
        if a%2 != 0:
            a -= 1
        b += a//2
        a = a//2
    else:
        if b%2 != 0:
            b -= 1
        a += b//2
        b = b//2
print(a,b)

Submission status: Accepted

Solution code:
a, b, k = map(int, input().split())
for i in range(k):
    if i % 2 == 0:
        if a % 2 == 1:
            a -= 1
        b += a// 2
        a //= 2
    else:
        if b % 2 == 1:
            b -= 1
        a += b// 2
        b //= 2
print(a,b)

Submission status: Accepted

Solution code:
a,b,k=map(int,input().split())
for i in range(k):
    if i%2:
        if b%2:b-=1
        a,b=a+b//2,b//2
    else:
        if a%2:a-=1
        a,b=a//2,b+a//2

print(a,b,sep=' ')

Submission status: Accepted

Solution code:
a,b,k=map(int,input().split())
def rule(a,b):
    if a%2==0:
        return a//2,b+a//2     
    else:
        return (a-1)//2,b+(a-1)//2

for i in range(k):
    if i%2==0:
        a,b=rule(a,b)
    else:
        b,a=rule(b,a)
print(a,b)

Submission status: Accepted

Solution code:
'''
Created on 2020/08/21

@author: harurun
'''
def main():
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write
  
  A,B,K=map(int,pin().split())
  for i in range(K):
    if i%2==0:
      if A%2==1:
        A-=1
      A=A//2
      B+=A
    else:
      if B%2==1:
        B-=1
      B=B//2
      A+=B 
  print(f"{A} {B}")
  return 
main()

Submission status: Accepted

Solution code:
a,b,k = map(int,input().split())
bit = 0
while k:
  if bit==0:
    if a%2!=0:
      a -= 1
    b += a//2
    a //= 2
    bit = 1
  else:
    if b%2!=0:
      b -= 1
    a += b//2
    b //= 2
    bit = 0
  k -= 1


print(a,b)

Submission status: Accepted

Solution code:
A,B,K=map(int,input().split())
for i in range(1,K+1):
    if i%2==1:
        if A%2==0:
            B=B+(A//2)
            A=A//2
        else:
            C=A-1
            B=B+(C//2)
            A=C//2
    elif i%2==0:
        if B%2==0:
            A=A+(B//2)
            B=B//2
        else:
            D=B-1
            A=A+(D//2)
            B=D//2
print(' '.join([str(A),str(B)]))

Submission status: Accepted

Solution code:
#Tenka1 Programmer Beginner Contest b
def move(me,you):
    if me%2==0:
        return me//2,you+me//2
    else:
        return (me-1)//2,you+(me-1)//2

a,b,k=map(int,input().split())
turn=True#takahashi true aoki false
cnt=0
while cnt<k:
    if turn:
        a,b=move(a,b)
        cnt+=1
        turn=False
    else:
        b,a=move(b,a)
        cnt+=1
        turn=True
print(a,b)

Submission status: Accepted

Solution code:
a, b, k = map(int, input().split())

for i in range(k):
    if i % 2 == 0:
        if a % 2 == 1:
            a -= 1
        tmp = a // 2
        a -= tmp
        b += tmp
    else:
        if b % 2 == 1:
            b -= 1
        tmp = b // 2
        a += tmp
        b -= tmp

print(a, b)

Submission status: Accepted

Solution code:
a, b, k = map(int, input().split(' '))
for i in range(0, k):
    if i % 2 == 0:
        if a % 2 != 0:
            a -= 1
        b += a // 2
        a -= a//2
    else:
        if b % 2 != 0:
            b -= 1
        a += b // 2
        b -= b//2
print(f'{max(0,a)} {max(0,b)}')

Submission status: Accepted

Solution code:
a, b, k = map(int, input().split())
for i in range(k):
    if i%2 == 0:
        if a%2 != 0:
            a -= 1
        temp = a//2
        b += temp
        a -= temp
    else:
        if b % 2 != 0:
            b -= 1
        temp = b//2
        a += temp
        b -= temp

print(a, b)

Submission status: Accepted

Solution code:
a, b, k = map(int, input().split())
for i in range(k):
  if i % 2 == 0:
    if a % 2 == 1:
      a -= 1
    num = a // 2
    a, b = a - num, b + num
  else:
    if b % 2 == 1:
      b -= 1
    num = b // 2
    a, b = a + num, b - num
print(a, b)

Submission status: Accepted

Solution code:
a, b, k = map(int, input().split())
for i in range(k):
    if i % 2 == 0:
        a //= 2
        b += a
    else:
        b //= 2
        a += b
print('{} {}'.format(a, b))

Submission status: Accepted

Solution code:
a,b,k = map(int,input().split())

tmp=1
for i in range(k):
    if tmp==1:
        b+=a//2
        a=a//2
        tmp=2
    else:
        a+=b//2
        b=b//2
        tmp=1

print(a,b)

Submission status: Accepted

Solution code:
*a,k=map(int,input().split())
for i in range(k):
    a[1-i%2]+=a[i%2]//2
    a[i%2]=(a[i%2]-a[i%2]%2)//2
print(*a)

Submission status: Accepted

Solution code:
import sys
readline = sys.stdin.readline


def main():
    abk = list(map(int, input().split()))
    k = abk[2]

    for i in range(k):
        i2 = i % 2
        if abk[i2] % 2 == 1:
            abk[i2] -= 1
        v = abk[i2] // 2
        abk[i2], abk[1 - i2] = abk[i2] - v, abk[1 - i2] + v
    print(abk[0], abk[1])


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
a, b, K = map(int, input().split())

for i in range(K):
    if i %2 == 0:
        if a % 2 == 1: a -= 1
        b += a // 2
        a //= 2
    else:
        if b % 2 == 1: b -= 1
        a += b // 2
        b //= 2
print(a, b)

Submission status: Accepted

Solution code:
a,b,k=map(int,input().split())
for i in range(k):
    if i%2:
        b-=b%2
        a+=b//2
        b//=2
    else:
        a-=a%2
        b+=a//2
        a//=2
print(a,b)

Submission status: Accepted

Solution code:
a, b, k = map(int, input().split())
for i in range(k):
  if i % 2 == 0:
    if a % 2 != 0:
      a = a - 1
    a = a // 2
    b = b + a
  else:
    if b % 2 != 0:
      b = b - 1
    b = b // 2
    a = a + b
print(a, end=" ")
print(b)

Submission status: Accepted

Solution code:
A, B, K = map(int, input().split())
k = 0
while True:
    if k == K:
        break
    if A % 2 == 1:
        A -= 1
    B += A // 2
    A -= A // 2
    k += 1
    if k == K:
        break
    if B % 2 == 1:
        B -= 1
    A += B // 2
    B -= B // 2
    k += 1
print(A, B)

Submission status: Accepted

Solution code:
a,b,k=map(int,input().split())
def co(x, y):
	x //= 2
	y += x
	return x, y

for i in range(k):
	if i % 2 == 0:
		a,b = co(a,b)
	else:
		b,a = co(b,a)
print(a,b)

Submission status: Accepted

Solution code:
a,b,k=map(int,input().split())
for i in range(k):
  if i%2:  # あおき
    if b%2:
      b -=1
    a += b//2
    b = b//2
  else:  # たかはし
    if a%2:
      a -=1
    b += a//2
    a = a//2
print(a,b)

Submission status: Accepted

Solution code:
a,b,k=map(int,input().split())
for i in range(k):
    if i%2==0:
      if a%2==1:
          a-=1
      b+=a//2
      a=a//2
    else:
      if b%2==1:
          b-=1
      a+=b//2
      b=b//2
print(a,b)

Submission status: Accepted

Solution code:
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    A, B, K = map(int, readline().split())
    for i in range(K):
        if i%2==0:
            if A%2==1:
                A -= 1
            B += A//2
            A //= 2
        else:
            if B%2==1:
                B -= 1
            A += B//2
            B //= 2
    print(A, B)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
A,B,K=map(int,input().split())
for i in range(K):
  if i%2==0:
    B+=A//2
    A//=2
  else:
    A+=B//2
    B//=2
print(A,B)

Submission status: Accepted

Solution code:
a, b, k = map(int, input().split())

for i in range(k):
    if i%2 == 0:
        b += a//2
        a = a//2
    else:
        a += b//2
        b = b//2
        
print(a, b)

Submission status: Accepted

Solution code:
a, b, k = map(int, input().split())

while k:
    if a%2 == 1:
        a -= 1
    b += a//2
    a = a//2
    k -= 1
    if k > 0:
        if b%2 == 1:
            b -= 1
        a += b//2
        b = b//2
        k -= 1
print(a, b)

Submission status: Accepted

Solution code:
import sys, math
from functools import lru_cache
import datetime
sys.setrecursionlimit(500000)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]


def main():
    A, B, K = mi()
    for i in range(K):
        if i%2 == 0:
            if A%2:
                A -= 1
            B += A//2
            A -= A//2
        else:
            if B%2:
                B -= 1
            A += B//2
            B -= B//2

    print(A, B)



if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections
from decimal import Decimal # 10進数で考慮できる

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

A, B, K = LI()

for k in range(K):
    if k % 2 == 0:
        if A % 2 == 1:
            A -= 1
        c = A // 2
        A -= c
        B += c
    else:
        if B % 2 == 1:
            B -= 1
        c = B // 2
        B -= c
        A += c
    
print(A, B)

Submission status: Accepted

Solution code:
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    A, B, K = LI()

    for i in range(K):
        if i % 2 == 0:
            if A % 2 == 1:
                A -= 1
            A //= 2
            B += A
        else:
            if B % 2 == 1:
                B -= 1
            B //= 2
            A += B

    print(A, B)

if __name__ == '__main__':
    resolve()

Submission status: Accepted

Solution code:
a,b,k = map(int,input().split())
for i in range(k):
    if i%2==0:
        if a%2 == 1:
            a-=1
        b+=a//2
        a-=a//2
    else:
        if b%2 == 1:
            b-=1
        a+=b//2
        b-=b//2
print(a,b)

Submission status: Accepted

Solution code:
a, b, k = [int(i) for i in input().split()]

for i in range(k):
  if i % 2 == 0:
    b += a // 2
    a = a // 2
  else:
    a += b // 2
    b = b // 2
print(a, b)

Submission status: Accepted

Solution code:
A,B,K=map(int,input().split())
for i in range(K):
  if i%2==0:
    if A%2==1:
      A-=1
    B+=A//2
    A//=2
  else:
    if B%2==1:
      B-=1
    A+=B//2
    B//=2
print(A,B)