Read problems statements in mandarin chinese, russian and vietnamese as well. 

Alice and Bob are playing a game. Alice initially has the number A and Bob has the number B. There are a total of N turns in the game, and Alice and Bob alternatively take turns. In each turn the player whose turn it is, multiplies his or her number by 2. Alice has the first turn.
Suppose after all the N turns, Alice's number has become C and Bob's number has become D. You want to calculate the integer division of the maximum number among C and D by the minimum number among C and D.

------ Input ------ 

The first line of the input contains an integer T denoting the number of test cases. The description of each testcase follows.
Each test case contains a single line with 3 integers A, B, and N.

------ Output ------ 

For each test case output a new line with a single integer which should be the answer.

------ Constraints ------ 

$1 ≤ T ≤ 100$
$1 ≤ A ≤ 1000000000$
$1 ≤ B ≤ 1000000000$
$1 ≤ N ≤ 1000000000$

------ Subtasks ------ 

$Subtask #1 (30 points): N ≤ 30$
$Subtask #2 (70 points): Original constraints$

----- Sample Input 1 ------ 
3

1 2 1

3 2 3

3 7 2
----- Sample Output 1 ------ 
1

3

2
----- explanation 1 ------ 
In the first testcase, the initial numbers are (A = 1, B = 2). There is only one turn. In this turn Alice multiplies her number by 2. Hence, we get (A = 2, B = 2). Therefore C = 2, and D = 2. max(C, D)/min(C, D) = 2/2 = 1. Hence the first output is 1.

In the second testcase, the initial numbers are (A = 3, B = 2). There three turns. In the first turn Alice multiplies her number by 2. Hence, we get (A = 6, B = 2). In the second turn Bob multiplies his number by 2. Hence, we get (A = 6, B = 4). In the third turn Alice multiplies her number by 2. Hence, we get (A = 12, B = 4). Therefore C = 12, and D = 4. max(C, D)/min(C, D) = 12/4 = 3. Hence the second output is 3.

In the third testcase, the initial numbers are (A = 3, B = 7). There two turns. In the first turn Alice multiplies her number by 2. Hence, we get (A = 6, B = 7). In the second turn Bob multiplies his number by 2. Hence, we get (A = 6, B = 14). Therefore C = 6, and D = 14. max(C, D)/min(C, D) = 14/6 = 2, because we are doing integer division. Hence the third output is 2.

Source: codechef | Difficulty: EASY
Tags: Constructive algorithms

Mathematics

Ad-hoc


Solutions:
for i in range(int(input())):
	(a, b, n) = map(int, input().split())
	if n % 2:
		a = a * 2
	maxi = max(a, b)
	mini = min(a, b)
	print(maxi // mini)


import math
t = int(input())
for _ in range(t):
	(a, b, n) = map(int, input().split())
	if n % 2:
		a = a * 2
	maxi = max(a, b)
	mini = min(a, b)
	print(maxi // mini)


for i in range(int(input())):
	(x, y, z) = map(int, input().split())
	if z % 2:
		x *= 2
	print(max(x, y) // min(x, y))


t = int(input())
for ni in range(t):
	(a, b, n) = map(int, input().split())
	if n & 1 == 1:
		a = a * 2
	print(max(a, b) // min(a, b))


t = int(input())
while t > 0:
	(a, b, n) = map(int, input().split())
	if n % 2 == 0:
		if a > b:
			print(a // b)
		else:
			print(b // a)
	elif 2 * a > b:
		print(2 * a // b)
	else:
		print(b // (2 * a))
	t -= 1


for _ in range(int(input())):
	(a, b, c) = map(int, input().split())
	if c % 2:
		a *= 2
	print(max(a, b) // min(a, b))


for _ in range(int(input())):
	(A, B, N) = map(int, input().split())
	if N & 1:
		A = 2 * A
	print(max(A, B) // min(A, B))


for _ in range(int(input())):
	(A, B, N) = map(int, input().split())
	A = A * 2 ** (N % 2)
	print(max(int(A / B), int(B / A)))


for _ in range(int(input())):
	(a, b, n) = map(int, input().split())
	if n % 2 == 1:
		a = a * 2
	print(max(a, b) // min(a, b))


for tc in range(int(input())):
	(a, b, n) = map(int, input().split())
	(ac, bc) = (0, 0)
	if n % 2 == 0:
		(ac, bc) = (n // 2, n // 2)
	else:
		(ac, bc) = (n // 2 + 1, n // 2)
	a = a * 2 ** (ac - bc)
	ans = int(max(a, b) / min(a, b))
	print(ans)


import math
t = int(input())
for i in range(t):
	(a, b, n) = map(int, input().split())
	if n % 2 == 1:
		a = a * 2
	(a, b) = (int(a), int(b))
	print(int(max(a, b) / min(a, b)))


for g in range(int(input())):
	(a, b, n) = map(int, input().split())
	if n % 2 == 1:
		a *= 2
	if a > b:
		print(a // b)
	else:
		print(b // a)


a = int(input(''))
for i in range(a):
	(A, B, N) = [int(x) for x in input('').split()]
	a1 = 0
	a2 = 0
	if N % 2 == 1:
		print(max(2 * A, B) // min(2 * A, B))
	else:
		print(max(A, B) // min(A, B))


for t in range(int(input())):
	(a, b, n) = map(int, input().split())
	count = 0
	if n % 2 == 1:
		print(max(2 * a, b) // min(2 * a, b))
	else:
		print(max(a, b) // min(a, b))


t = int(input())
for i in range(t):
	(a, b, n) = map(int, input().split())
	w1 = n % 2
	if w1 == 0:
		print(max(a, b) // min(a, b))
	else:
		c = a * 2
		d = b
		print(max(c, d) // min(c, d))


T = int(input())
for i in range(0, T):
	(a, b, n) = map(int, input().split())
	if n % 2 == 1:
		a *= 2
	print(max(a, b) // min(a, b))


t = int(input())
for i in range(0, t):
	(a, b, n) = map(int, input().split())
	if n % 2 != 0:
		a = a * 2
	if a > b:
		print(int(a / b))
	else:
		print(int(b / a))


z = int(input())
for i in range(z):
	(a, b, c) = map(int, input().split())
	if c % 2 != 0:
		a = a * 2
	if a > b:
		print(a // b)
	else:
		print(b // a)


from math import ceil
for i in range(int(input())):
	(a, b, n) = map(int, input().split())
	if n % 2 == 0:
		if a >= b:
			print(int(a / b))
		else:
			print(int(b / a))
	else:
		a = a * 2
		if a >= b:
			print(int(a / b))
		else:
			print(int(b / a))


import math as m
for _ in range(int(input())):
	(a, b, n) = map(int, input().split())
	if n % 2 == 0:
		d = b * 2
	else:
		d = b
	c = a * 2
	ans = max(c, d) // min(c, d)
	print(ans)


t = int(input())
for s in range(t):
	(a, b, n) = map(int, input().split())
	if n % 2 == 1:
		d = b
	else:
		d = b * 2
	c = a * 2
	print(max(c, d) // min(c, d))


for _ in range(int(input())):
	(a, b, c) = map(int, input().split())
	if c % 2 == 0:
		c = a * 2
		d = b * 2
		print(int(max(c, d) / min(c, d)))
	else:
		c = a * 2
		d = b
		print(int(max(c, d) / min(c, d)))


for _ in range(int(input())):
	(a, b, n) = map(int, input().split())
	if n % 2 != 0:
		a = a * 2
	res = max(a, b)
	rem = min(a, b)
	print(int(res // rem))


T = int(input())
for k in range(0, T):
	(a, b, N) = list(map(int, input().split()))
	if N % 2 != 0:
		a = a * 2
	if a > b:
		print(a // b)
	elif b >= a:
		print(b // a)


t = input()
for x in range(0, int(t)):
	(a, b, c) = map(int, input().split())
	if c % 2 != 0:
		a = a * 2
	if a > b:
		print(a // b)
	elif b >= a:
		print(b // a)


n = int(input())
for i in range(n):
	(a, b, c) = map(int, input().split())
	if c % 2 != 0:
		a = a * 2
	if a > b:
		print(a // b)
	elif b >= a:
		print(b // a)


n = int(input())
for i in range(n):
	(a, b, n1) = map(int, input().split())
	if n1 == 1 or n1 % 2 == 1:
		a = a * 2
	if a > b:
		print(a // b)
	else:
		print(b // a)


for i in range(int(input())):
	(a, b, n) = map(int, input().split())
	(c, d) = (0, 0)
	if n % 2 == 0:
		c = n / 2 * 2 * a
		d = n / 2 * 2 * b
	elif n == 1:
		c = 2 * a
		d = b
	else:
		c = (n - 1) * 2 * a
		d = n // 2 * 2 * b
	v = max(c, d)
	r = min(c, d)
	print(int(v / r))


import math
t = int(input())
for l in range(t):
	(a, b, n) = map(int, input().split())
	if n % 2 == 0:
		print(max(a, b) // min(a, b))
	else:
		print(max(2 * a, b) // min(2 * a, b))


t = int(input())
for test in range(t):
	(a, b, n) = map(int, input().split())
	l = n % 2
	if l == 1:
		a = a * 2
		s = max(a, b)
		s2 = min(a, b)
		print(s // s2)
	else:
		s = max(a, b)
		s2 = min(a, b)
		print(s // s2)


for _ in range(int(input())):
	(a, b, n) = map(int, input().split())
	if n % 2 == 0:
		x = max(a, b) // min(a, b)
		print(x)
	elif n % 2 != 0:
		n1 = n - 1
		x = max(a * 2, b) // min(a * 2, b)
		print(x)


ko = int(input())
for i in range(ko):
	(a, b, n) = map(int, input().split())
	if n % 2 == 1:
		a = a * 2
	if a > b:
		print(a // b)
	else:
		print(b // a)


for i in range(int(input())):
	(a, b, p) = map(int, input().split())
	if p % 2 == 1:
		a *= 2
	if a > b:
		print(a // b)
	else:
		print(b // a)


t = int(input())
while t:
	(a, b, n) = [int(i) for i in input().split()]
	if n % 2 == 0:
		print(max(a, b) // min(a, b))
	else:
		print(max(2 * a, b) // min(2 * a, b))
	t -= 1


for i in range(int(input())):
	(a, b, c) = map(int, input().split(' '))
	if c % 2 != 0:
		a = 2 * a
	(d, e) = (max(a, b), min(a, b))
	print(d // e)


for i in range(int(input())):
	(a, b, n) = map(int, input().split(' '))
	if n % 2 == 0:
		print(max(a, b) // min(a, b))
	elif 2 * a > b:
		print(2 * a // b)
	else:
		print(b // (a * 2))


def solve(*args):
	(a, b, n) = args
	if n & 1:
		a *= 2
	if a > b:
		(a, b) = (b, a)
	return b // a

def do_codechef():
	for t in range(int(input())):
		(a, b, n) = map(int, input().split(' '))
		print(solve(a, b, n))
do_codechef()
exit()


numberlist = [list(map(int, input('').split())) for _ in range(int(input('')))]
for (a, b, n) in numberlist:
	if n % 2 == 0:
		print(max(a, b) // min(a, b))
	else:
		a = a * 2
		print(max(a, b) // min(a, b))


t = int(input())
for i in range(t):
	(A, B, N) = list(map(int, input().split()))
	if N % 2 == 0:
		C = A * 2 * (N // 2)
		D = B * 2 * (N // 2)
		print(max(C, D) // min(C, D))
	else:
		C = A * 2
		D = B
		print(max(C, D) // min(C, D))


T = int(input())
for i in range(T):
	(A, B, N) = map(int, input().split())
	if N % 2 == 0:
		print(int(max(A, B) / min(A, B)))
	if N % 2 == 1:
		print(int(max(2 * A, B) / min(2 * A, B)))


import math
for _ in range(int(input())):
	(a, b, n) = map(int, input().split())
	if n % 2 == 0:
		ans = max(a, b) / min(a, b)
	if n % 2 == 1:
		ans = max(2 * a, b) / min(2 * a, b)
	print(int(ans))


for i in range(int(input())):
	(a, b, n) = list(map(int, input().split()))
	if n % 2 != 0:
		a *= 2
	print(str(max(a, b) // min(a, b)))


from math import *
T = int(input())
for test in range(T):
	(A, B, N) = map(int, input().split())
	if N % 2 == 0:
		print(floor(max(A, B) / min(A, B)))
	else:
		A = 2 * A
		print(floor(max(A, B) / min(A, B)))


for i in range(int(input())):
	(a, b, n) = map(int, input().split())
	if n % 2 == 1:
		ans = max(a * 2, b) // min(a * 2, b)
		print(ans)
	else:
		ans = max(a, b) // min(a, b)
		print(ans)