Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import math
- def f(m, n = 20, turn = 0):
- if n+m<=40 and (turn == 2 or turn == 4): # Набрали меньше 40 ровно на 3
- return True
- elif n+m<=40 and turn < 4: # Набрали меньше 40 до 3
- return False
- elif n+m>40 and turn == 4: # Не набрали 40 на 3
- return False
- if turn%2 == 1:
- return f(m-1, n, turn+1) or f(math.ceil(m/2), n, turn+1) \
- or f(m, n-1, turn+1) or f(m, math.ceil(n/2), turn+1)
- else:
- return f(m-1, n, turn+1) and f(math.ceil(m/2), n, turn+1) \
- and f(m, n-1, turn+1) and f(m, math.ceil(n/2), turn+1)
- def Check2(m, n = 20, turn = 0):
- if n+m <= 40 and turn == 2: # Набрали меньше 40 ровно на 3
- return True
- elif n+m <= 40 and turn < 2: # Набрали меньше 40 до 3
- return False
- elif n+m > 40 and turn == 2: # Не набрали 40 на 3
- return False
- if turn % 2 == 1:
- return Check2(m-1, n, turn+1) or Check2(math.ceil(m/2), n, turn+1) \
- or Check2(m, n-1, turn+1) or Check2(m, math.ceil(n/2), turn+1)
- else:
- return Check2(m-1, n, turn+1) and Check2(math.ceil(m/2), n, turn+1) \
- and Check2(m, n-1, turn+1) and Check2(m, math.ceil(n/2), turn+1)
- for s in range(20, 100):
- if f(s) and not Check2(s):
- print(s)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement