Tony's Log

Algorithms, Distributed System, Machine Learning

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

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;
    }
};
posted on 2015-10-13 05:34  Tonix  阅读(180)  评论(0编辑  收藏  举报