美文网首页
292. Nim Game

292. Nim Game

作者: 殷水臣 | 来源:发表于2017-02-20 20:18 被阅读0次

这道题的证明可以去网上搜,只要任何一步轮到自己拿时还剩4的倍数个必输,想赢同理,因此需要保证自己每次拿完之后是4的倍数。

class Solution {
public:
    bool canWinNim(int n) {
        return n % 4;
    }
};

注意不写不必要的代码,多利用返回值。

相关文章

  • Leetcode-292Nim Game

    292. Nim Game You are playing the following Nim Game with...

  • Leetcode PHP题解--D64 292. Nim Gam

    D64 292. Nim Game 题目链接 292. Nim Game 题目分析 假设你和朋友玩一个捡石头的游戏...

  • 2019-02-09

    LeetCode 292. Nim Game Description You are playing the fo...

  • 292. Nim Game

    292. Nim Game【思路】搬石头游戏,一堆石头,几个人玩,每次可以搬动1到3个石头,谁把一堆石头搬空谁就赢...

  • 292. Nim Game

    Problem You are playing the following Nim Game with your ...

  • 292. Nim Game

    1.描述 You are playing the following Nim Game with your fri...

  • 292. Nim Game

    C++ 最优解 简化bool

  • 292. Nim Game

    You are playing the following Nim Game with your friend: ...

  • 292. Nim Game

    You are playing the following Nim Game with your friend: ...

  • 292. Nim Game

    这道题的证明可以去网上搜,只要任何一步轮到自己拿时还剩4的倍数个必输,想赢同理,因此需要保证自己每次拿完之后是4的...

网友评论

      本文标题:292. Nim Game

      本文链接:https://www.haomeiwen.com/subject/tfgewttx.html