64.Nim游戏
题目内容:
代码及思路:
#include<iostream>
using namespace std;
class Solution {
public:
bool canWinNim(int n) {
//根据巴什博奕的思想,只要n%(m+1)!=0则先手获胜,这里的m为最多拿掉的块数
//此时题目中m=3
if (n % 4 == 0)
return false;
else
return true;
}
};
int main()
{
Solution* object = new Solution();
int n;
cin >> n;
bool res = object->canWinNim(n);
cout << res << endl;
}