Advertisement
DaniDori

Тип 21 № 27804

Feb 1st, 2024
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. def foo(s, cnt):
  2. if s >= 68 and cnt % 2 == 1:
  3. return False
  4. elif s >= 68 and (cnt == 2 or cnt == 4):
  5. return True
  6. if cnt % 2 == 1:
  7. #Ходит Ваня победитель
  8. #Нам достаточно, чтобы хотябы один ход был хорошим
  9. return foo(s + 1, cnt + 1) or foo(s + 4, cnt + 1) or foo(s * 5, cnt + 1)
  10. else:
  11. #Мы должны выйигрывать при любой игре соперника
  12. return foo(s + 1, cnt + 1) and foo(s + 4, cnt + 1) and foo(s * 5, cnt + 1)
  13.  
  14. def fooBe(s, cnt):
  15. if s >= 68 and cnt == 2:
  16. return False
  17. elif s >= 68 and (cnt == 1 or cnt > 2):
  18. return True
  19. if cnt % 2 == 1:
  20. #Ходит Ваня победитель
  21. #Нам достаточно, чтобы хотябы один ход был хорошим
  22. return foo(s + 1, cnt + 1) or foo(s + 4, cnt + 1) or foo(s * 5, cnt + 1)
  23. else:
  24. #Мы должны выйигрывать при любой игре соперника
  25. return foo(s + 1, cnt + 1) and foo(s + 4, cnt + 1) and foo(s * 5, cnt + 1)
  26.  
  27.  
  28. for i in range(1, 67):
  29. if fooBe(i, 0) and foo(i, 0):
  30. print(i)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement