Same as LintCode 'Coins in a line'. Here is mind-flow: 4 is a definite lose, for (4 + 1), (4 + 2), (4 + 3), we can put the other player into slot 4 - and this deduction continues.. so:
class Solution { public: bool canWinNim(int n) { return n % 4; } };