必胜策略:第一次拿 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;
}
};
- 本文作者: royalchen
- 本文链接: http://www.royalchen.com/2018/08/03/leetcode-292-nim-game/
- 版权声明: 本博客所有文章除特别声明外,均采用 MIT 许可协议。转载请注明出处!