Advertisement
qekaqeka

2712 21 КЕГЭ

Jun 7th, 2023
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. def m(n1, n2, k, p, w):
  2. if k > max(w):
  3. return False
  4. if p:
  5. if n1 >= 50 or n2 >= 50:
  6. if n1+n2 <= 109:
  7. return False
  8. else:
  9. return True
  10.  
  11. r = [m(n1 + 1, n2, k + 1, not p, w), m(n1 + 2, n2, k + 1, not p, w), m(n1 * 2, n2, k + 1, not p, w),
  12. m(n1, n2 + 1, k + 1, not p, w), m(n1, n2 + 2, k + 1, not p, w), m(n1, n2 * 2, k + 1, not p, w)]
  13.  
  14. return any(r)
  15. else:
  16. if n1 >= 50 or n2 >= 50:
  17. if n1+n2 <= 109:
  18. if k in w:
  19. return True
  20. else:
  21. return False
  22. else:
  23. return False
  24.  
  25. r = [m(n1 + 1, n2, k + 1, not p, w), m(n1 + 2, n2, k + 1, not p, w), m(n1 * 2, n2, k + 1, not p, w),
  26. m(n1, n2 + 1, k + 1, not p, w), m(n1, n2 + 2, k + 1, not p, w), m(n1, n2 * 2, k + 1, not p, w)]
  27.  
  28. return all(r)
  29.  
  30. for s1 in range(1, 49 + 1):
  31. for s2 in range(1, 49 + 1):
  32. if m(s1, s2, 1, False, [3, 5]) and not(m(s1, s2, 1, False, [3])):
  33. print(s1, s2)
  34.  
  35.  
  36.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement