В игре, описанной
Укажите минимальное и максимальное из таких
В ответе запишите сначала минимальное значение, затем максимальное.
Ответ:
Приведём решение на языке Python.
def f(x, y, h):
if h == 3 and x + y >= 41:
return 1
if h == 3 and x + y < 41:
return 0
if h < 3 and x + y >= 41:
return 0
else:
if h % 2 == 0:
if x > y:
return f(x + 1, y, h + 1) or f(x + 2, y, h + 1) or f(x + 3, y, h + 1) or f(x, y * 2, h + 1)
elif x < y:
return f(x, y + 1, h + 1) or f(x, y + 2, h + 1) or f(x, y + 3, h + 1) or f(x * 2, y, h + 1)
elif x == y:
return f(x + 1, y, h + 1) or f(x + 2, y, h + 1) or f(x + 3, y, h + 1) or f(x, y + 1, h + 1) or f(x, y + 2, h + 1) or f(x, y + 3, h + 1)
else:
if x > y:
return f(x + 1, y, h + 1) and f(x + 2, y, h + 1) and f(x + 3, y, h + 1) and f(x, y * 2, h + 1)
elif x < y:
return f(x, y + 1, h + 1) and f(x, y + 2, h + 1) and f(x, y + 3, h + 1) and f(x * 2, y, h + 1)
elif x == y:
return f(x + 1, y, h + 1) and f(x + 2, y, h + 1) and f(x + 3, y, h + 1) and f(x, y + 1, h + 1) and f(x, y + 2, h + 1) and f(x, y + 3, h + 1)
a = set()
for x in range(1, 35):
if f(5, x, 0) == 1:
a.add(x)
print(min(a), max(a))
Ответ: 20 29.

