Advertisement
qekaqeka

5414 Б - ПОЛЯКОВ

Apr 24th, 2023 (edited)
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. def m(n, k ,p):
  2. if k > 3:
  3. return False
  4. if p:
  5. if n <= 10:
  6. return False
  7.  
  8. return any([m(n-10, k+1, not p), m(n//3, k+1, not p)])
  9. else:
  10. if n <= 10 and (k == 3):
  11. return True
  12.  
  13. return all([m(n-10, k+1, not p), m(n//3, k+1, not p)])
  14.  
  15. c = 0
  16. a = list()
  17. for s in range(11, 9999 + 1):
  18. if m(s, 0, True):
  19. a.append(s)
  20.  
  21. print(min(a), max(a))
  22.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement