博弈论题目集 (持续更新)

巴什博弈  HDU 1846

1、  本游戏是一个二人游戏;
2、  有一堆石子一共有n个;
3、  两人轮流进行;
4、  每走一步可以取走1…m个石子;
5、  最先取光石子的一方为胜;

这个应该比较好推:

如果 n % (m+1)==0 后手胜利 否则 先手胜利

#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main(){
	int t;
	scanf("%d",&t);
	while(t--){
		int n,m;
		scanf("%d%d",&n,&m);
		if(n%(m+1)==0) printf("second\n");
		else printf("first\n");
	}
	return 0;
}

猜你喜欢

转载自blog.csdn.net/weixin_43824564/article/details/107027758