题意:针对Nim博弈,给定上一个集合,然后下面有 m 个询问,每个询问有 x 堆石子 ,问你每次只能从某一个堆中取出 y 个石子,并且这个 y 必须属于给定的集合,问你先手胜还是负. 析:一个很简单的博弈,对于每组数据,要先处理出SG函数, 然后使用组合游戏和来解决就ok了,对于求sg函数,很明显,就是求所有的mex,也就是未出现过的最小自然数.最后取异或就ok了. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000"…
A New Stone Game Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 5769 Accepted: 3158 Description Alice and Bob decide to play a new stone game.At the beginning of the game they pick n(1<=n<=10) piles of stones in a line. Alice and Bob…
Treblecross is a two player gamewhere the goal is to get three X in a row on a one-dimensional board. At the startof the game all cells in the board is empty. In each turn a player puts a X in an empty cell, and if that results in there beingthree X…
题目链接:uva 1378 - A Funny Stone Game 题目大意:两个人玩游戏,对于一个序列,轮流操作.每次选中序列中的i,j,k三个位置要求i<j≤k,然后arr[i]减1,对应的arr[j]和arr[k]加1,不能操作的人输,问先手是否必胜.必胜的话给出字典序最下的必胜方案.负责输出-1. 解题思路:首先预处理出各个位置上的SG值,然后对于给定序列,枚举位置转移状态后推断是否为必败态就可以. #include <cstdio> #include <cstring&…