巴什博弈:Brave Game

我国民间有个古老的游戏:就是有物品若干堆,(物品可以是火柴,围棋都可以)。

两个人轮流从堆中取若干件,规定取光物体者为胜。这个就是我们今天要研究的组合游戏。

#include<iostream>
using namespace std;
int main()
{
    int t,n,m;
    cin>>t;
    while(t--)
    {
        cin>>n>>m;
        if(n%(m+1)!=0)
        cout<<"first"<<endl;
        else
        cout<<"second"<<endl;
    }
    return 0;
}

http://acm.hdu.edu.cn/showproblem.php?pid=1846

证明:

假设n=m+1

那后取者必赢

那如果n=(m+1)*r+s

甲取s个 

乙取k个

甲再取(m+1-k)(这很关键)

那n=(m+1)*(r-1)

so  如果能使n==(m+1)*r+s

那么先取者必赢

如果你够坚强够勇敢,你就能驾驭他们
原文地址:https://www.cnblogs.com/liuzhaojun/p/10753474.html