首页 > 其他 > 详细

LeetCode "Nim Game"

时间:2015-10-13 06:58:48      阅读:426      评论:0      收藏:0      [点我收藏+]

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;
    }
};

LeetCode "Nim Game"

原文:http://www.cnblogs.com/tonix/p/4873393.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!