Advertisement
qekaqeka

6964 Б КЕГЭ

May 1st, 2023
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. def m(n, k, p, w):
  2. if k > 5:
  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, False, [3, 1]):
  20. a1.append(s)
  21.  
  22. for s in range(1, 99 + 1):
  23. if m(s, 0, False, [5, 3, 1]):
  24. a2.append(s)
  25.  
  26. for el in a2:
  27. if not(el in a1):
  28. print(el)
  29.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement