1. 程式人生 > >Return of the Nim----Nim博弈+威佐夫博弈 山東省第八屆省賽A題

Return of the Nim----Nim博弈+威佐夫博弈 山東省第八屆省賽A題

Sherlock and Watson are playing the following modified version of Nim game:

  • There are n piles of stones denoted as ,,...,, and n is a prime number;
  • Sherlock always plays first, and Watson and he move in alternating turns. During each turn, the current player must perform either of the following two kinds of moves:
    1. Choose one pile and remove k
      (k >0) stones from it;
    2. Remove k stones from all piles, where 1≤kthe size of the smallest pile. This move becomes unavailable if any pile is empty.
  • Each player moves optimally, meaning they will not make a move that causes them to lose if there are still any better or winning moves.

Giving the initial situation of each game, you are required to figure out who will be the winner