博弈论之巴什博弈
问题模型
① 两个人从
n
n
n个物体中取,取物品,规定每次至少取一个,最多取
m
m
m个,最后取光者得胜。
结论:当n%(m+1)==0先手必败,否则先手必胜
② 两个人从
n
n
n个物体中取,取物品,规定每次至少取一个,最多取
m
m
m个,最后取光者失败。
结论:当(n-1)%(m+1)==0先手必败,否则先手必胜
例题
Seek the Joker I
code
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5+5;
ll n, k, t;
int main()
{
cin >> t;
while(t--)
{
cin >> n >> k;
if((n-1) % (k+1))
cout << "yo xi no forever!" << endl;
else
cout << "ma la se mi no.1!" << endl;
}
return 0;
}