题意分析:给定数列(A,B)(A>B),任取两数之差,若不含于数列(A,B)则添加得(A.B,C)重复任取两数之差且不重复得(A,B,C,...),求()最终含有多少个数
解法:
暴力解法打表观察
def solve(*args):
a, b = args
s, t = {a, b}, {a - b}
while True:
for i in s:
for j in s:
if i - j > 0 and i - j not in s:
t.add(i - j)
if len(t) == 0:
return len(s) - 2
else:
s.update(t)
t.clear()
for i in range(1, 20):
for j in range(1, 20):
if i > j:
print(i, j, solve(i, j))
可以发现:
A奇A必赢
A偶B奇B赢,B偶A赢
a, b = map(int, input().split())
if a % 2 == 0 and b % 2 != 0:
print("B")
else:
print("A")