Advertisement
qekaqeka

6964 В КЕГЭ

May 1st, 2023
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. def m(n, k, p, w):
  2. if k > max(w):
  3. return False
  4. if p:
  5. if n >= 100 and k in w:
  6. return True
  7.  
  8. return any([m(n + 2, k + 1, not p, w),m(n + 4, k + 1, not p, w),m(n * 2, k + 1, not p, w)])
  9. else:
  10. if n >= 100:
  11. return False
  12.  
  13. return all([m(n + 2, k + 1, not p, w),m(n + 4, k + 1, not p, w),m(n * 2, k + 1, not p, w)])
  14.  
  15. a1 = list()
  16. a2 = list()
  17.  
  18. for s in range(1, 99 + 1):
  19. if m(s, 0, True, [2, 0]):
  20. a1.append(s)
  21.  
  22. for s in range(1, 99 + 1):
  23. if m(s, 0, True, [4, 2, 0]):
  24. a2.append(s)
  25.  
  26. a3 = list()
  27.  
  28. for el in a2:
  29. if not(el in a1):
  30. a3.append(el)
  31.  
  32. print(min(a3), max(a3))
  33.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement