HackerRank "Misère Nim"

Another easy one solved by Sprague-Grundy theorem.

Each pile is a sub-game, so you need to XOR SG value of all substates - since you can move # of 1 - #(pile), so the SG value is the #(pile) itself.

Also, please handle the special case of 1,1,1,1....

原文地址:https://www.cnblogs.com/tonix/p/8124948.html