Блог пользователя Confused101

Автор Confused101, история, 8 лет назад, По-английски

Numbers 1....N are written in table (3 <= N <= 1000), at each step one player choose some number and mark it as visited, player wins if he can make 3 consecutive numbers visited in his turn. Who will win the game if both play optimally? game is 2-player game with alternating turns.

  • Проголосовать: нравится
  • +5
  • Проголосовать: не нравится

»
8 лет назад, # |
  Проголосовать: нравится +4 Проголосовать: не нравится

It's obvious that if we mark some number x, an opponent instantly loses if he takes any number y : |x - y| ≤ 2.

Let's define f(n) the answer for table of "length" n. We know that f(3) = 1 (1st player wins on such board anyways). Trying all possible moves we can easily calculate f(n): by taking some number x (1 ≤ x ≤ n), we split the table into two parts of lengths max(0, x - 3) and max(0, n - x - 2), since there's no point of keeping neighbouring to x unavailable numbers on the table.

If you still have some difficulties, googling "sprague grundy theory" shuold help.