Advertisement
qekaqeka

2712 19 КЕГЭ

Jun 7th, 2023
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. def m(n1, n2, k, p, w, l):
  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, l + 'А'), m(n1 + 2, n2, k + 1, not p, w, l + 'Б'), m(n1 * 2, n2, k + 1, not p, w, l + 'В'),
  12. m(n1, n2 + 1, k + 1, not p, w, l + 'А'), m(n1, n2 + 2, k + 1, not p, w, l + 'Б'), m(n1, n2 * 2, k + 1, not p, w, l + 'В')]
  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, l + 'А'), m(n1 + 2, n2, k + 1, not p, w, l + 'Б'), m(n1 * 2, n2, k + 1, not p, w, l + 'В'),
  26. m(n1, n2 + 1, k + 1, not p, w, l + 'А'), m(n1, n2 + 2, k + 1, not p, w, l + 'Б'), m(n1, n2 * 2, k + 1, not p, w, l + 'В')]
  27. if k == 2 and all(r):
  28. print(l)
  29. return all(r)
  30.  
  31. for s in range(1, 49 + 1):
  32. if m(24, s, 1, True, [4], ''):
  33. print(s)
  34.  
  35.  
  36.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement