其他分享
首页 > 其他分享> > 1300 · 巴什博弈

1300 · 巴什博弈

作者:互联网

class Solution {
public:
    /**
     * @param n: an integer
     * @return: whether you can win the game given the number of stones in the heap
     */
    bool canWinBash(int n) {
        int m=3;

        if(n%(m+1)){
            return true;
        }
        else return false;

        // Write your code here
    }
};

在先取完者胜的巴什博弈中,若n可被m+1整除,则后手方必胜,否则先手方必胜。

其中 n表示物品总数;m表示每次可以拿的最大个数。

标签:stones,return,int,1300,必胜,博弈,巴什
来源: https://blog.csdn.net/Aiqing_/article/details/121963300