amplification-battle

See Russian Translation

Adam and Bob are playing a game. The game is parameterized by the three integers a,b,c. They start out with the integer 1, with Adam going first. Suppose the current integer is S. On a player's turn, he may change the current integer to any integer between a×S and b×S, inclusive. The first player to make the current integer be at least as large as c is declared the winner. Given that Adam and Bob play optimally, return the winner of the game. 

Input format:

The first line of input will contain an integer T, denoting the number of test cases.
Each test case will be given on one line, which contains 3 integers, a,b,c

Output format:

Print the name of the person who will win for each test case on a separate line.

Constraints:

For all subtasks
1 ≤ T ≤ 10^4

30 pts:
2 ≤ a ≤ b ≤ 10
2 ≤ c ≤ 20

60 pts:
2 ≤ a ≤ b ≤ 50
2 ≤ c ≤ 1,000

10 pts:
2 ≤ a ≤ b ≤ 100
2 ≤ c ≤ 10^18

SAMPLE INPUT
6
2 2 10
2 10 20
10 10 3
2 3 100
22 40 500
2 100 1000000000000000000

SAMPLE OUTPUT
Bob
Bob
Adam
Adam
Bob
Adam

Explanation

Note, the fourth and fifth case does not fit within the limits of the first subtask, and the sixth case does not fit within the limits of the first or second subtask. 

In the first case, a player turn consists of multiplying the current integer by 2. Thus, Adam turns the number to 2, Bob makes it 4, Adam makes it 8, then Bob makes it 16. This is at least 10, so Bob is the winner.

In the second case, no matter what Adam does on the very first turn, Bob can just multiply the integer by 10 to make it exceed 20. So, Bob can always win.

Difficulty: EASY
Tags: Dynamic programming

Game theory

Mathematics
Skill types: Dynamic programming

Starter code:

Solutions:
'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
s = 1
t = int(input())
for i in range(0, t, 1):
	line = input()
	one, two, three = line.split()
	a = int(one)
	b = int(two)
	c = int(three)
	temps = s
	count = 1
	while temps < c:
		start = a * temps
		end = b * temps
		if end >= c:
			temps = end
		else:
			if count % 2 == 0:
				temps = end
			else:
				temps = start
		count += 1
	if (count - 1) % 2 == 0:
		print("Bob")
	else:
		print("Adam")


import math
t = eval(input())
for i in range(0,t):
	str = input()
	ls = list(map(int ,str.split()))
	a = ls[0]
	b = ls[1]
	c = ls[2]
	base = a*b
	r = math.log(c,base)
	r = int(r)
   # print r
	rem = float(c)/float((base ** r))
   # print rem
	p = math.ceil(rem) #give atleast p
  #  print p
	if p <= 1:
		print("Bob")
		continue
	n = math.ceil(p/float(b)) #get atleast n
   #  print n
	if n <= 1:
		print("Adam")
	else:
		print("Bob")
	


# your code goes here


t = eval(input())
for i in range(t):
	a,b,c = list(map(int, input().split()))
	y = 0
	while c!=1:
		if y%2==0:
			k = c/b
			q = (1.0*c)/b
			
		else:
			
			k = c/a
			q = (1.0*c)/a
		if k==q:
			c=k
		else:
			c = k+1
			
		y+=1
	if y%2==0:
		print('Bob')
	else:
		print('Adam')
			
	


# your code goes here
def gcd(a,b):
	while b:
		a,b = b,a%b
	return a
	
	


from math import log

t = eval(input())
for i in range(t):
	a,b,c = list(map(int, input().split()))
	y = 0
	while c!=1:
		if y%2==0:
			k = c/b
			q = (1.0*c)/b
			if k==q:
				c=k
			else:
				c = k+1
		else:
			
			k = c/a
			q = (1.0*c)/a
			if k==q:
				c=k
			else:
				c = k+1
		y+=1
	if y%2==0:
		print('Bob')
	else:
		print('Adam')
			
	


t=int(eval(input()))
for i in range(0,t):
	a,b,c=list(map(int,input().split()))
	ans=1
	p=a*b
	while(p<c):
		p*=a*b
	p/=a*b
	if p*a>=c or p*b>=c :
		print("Adam")
	else:
		print("Bob")


import math
#print 'Hello World!'

def canAWin(a,b,c, r , isA, isMax):
	if r * b >= c:
		return isA
   
	m = a
	n = b
	if isMax:
		m = b
		n = a

	if isA:
		return canAWin(a,b,c,r*m,False, isMax)
	else:
		return canAWin(a,b,c,r*n,True, isMax)



def play(a,b,c):
	if canAWin(a,b,c,1,True,True) or canAWin(a,b,c,1,True,False):
		print ("Adam")
	else:
		print ("Bob")



def read_input():
	t = int(input())
	input = []
	for N in range(t):
		input.append(input())
	
	for inp in input:
		inp_arr = inp.split()
		play(int(inp_arr[0]),int(inp_arr[1]),int(inp_arr[2]))
		
	

read_input()



T = int(input())

for t in range(T):
	a, b, c = list(map(int, input().split(' ')))

	ablo = 1
	abhi = a * b

	while abhi < c:
		ablo = ablo * a * b
		abhi = abhi * a * b

	if ablo * b < c:
		print("Bob")
	else:
		print("Adam")


t = eval(input())
for i in range(t):
	a,b,c = list(map(int, input().split()))
	y = 0
	while c!=1:
		if y%2==0:
			l = b
			
		else:
			
			l = a
			
		k = c/l
		q = (1.0*c)/l
		if k==q:
			c=k
		else:
			c = k+1
			
		y+=1
	if y%2==0:
		print('Bob')
	else:
		print('Adam')