LeetCode—292. Nim Game


必胜策略:第一次拿 n%4个,然后不管对手拿多少个,自己拿 (n-对手拿的个数)就必赢了

//url:https://leetcode.com/problems/nim-game/description/

class Solution {
public:
    bool canWinNim(int n) {
        if(n%4>0)
            return true;
        return false;
    }
};


发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注