D - Partitioning Game Time Limit:4000MS     Memory Limit:32768KB     64bit IO Format:%lld & %llu Submit Status Description Alice and Bob are playing a strange game. The rules of the game are: Initially there are n piles. A pile is formed by some cell…
传送门 1199 - Partitioning Game    PDF (English) problem=1199" style="color:rgb(79,107,114)">Statistics problem=1199" style="color:rgb(79,107,114)">Forum Time Limit: 4 second(s) Memory Limit: 32 MB Alice and Bob are playin…
题意:可以把一堆石子分成不相等的两堆,不能操作为败 思路:把一个石子拆成两个,变成了两个独立的游戏,mex里加上两者的sg异或.sg打表. 代码: #include<set> #include<map> #include<stack> #include<cmath> #include<queue> #include<vector> #include<cstdio> #include<cstring> #incl…
S-Nim HDU 1536 博弈 sg函数 题意 首先输入K,表示一个集合的大小,之后输入集合,表示对于这对石子只能去这个集合中的元素的个数,之后输入 一个m表示接下来对于这个集合要进行m次询问,之后m行,每行输入一个n表示有n个堆,每堆有n1个石子,问这一行所表示的状态是赢还是输,如果赢输入W否则L. 解题思路 如果没有每次取石子个数的限制的话,那么仅仅需要把每堆石子的个数进行异或运算即可,如果结果不是1,那么先手赢,反之后手赢. 但是这里对每次取石子的个数进行了限制,每次只能从几个数中进行…
Alice and Bob are playing a strange game. The rules of the game are: 1.      Initially there are n piles. 2.      A pile is formed by some cells. 3.      Alice starts the game and they alternate turns. 4.      In each tern a player can pick any pile…
F - Again Stone Game Time Limit:2000MS     Memory Limit:32768KB     64bit IO Format:%lld & %llu Submit Status Description Alice and Bob are playing a stone game. Initially there are n piles of stones and each pile contains some stone. Alice stars the…
题意:与原来基本的尼姆博弈不同的是,可以将一堆石子分成两堆石子也算一步操作,其它的都是一样的. 分析:由于石子的堆数和每一堆石子的数量都很大,所以肯定不能用搜索去求sg函数,现在我们只能通过找规律的办法求得sg的规律. 通过打表找规律可以得到如下规律:if(x%4==0) sg[x]=x-1; if(x%4==1||x%4==2) sg[x]=x; if(x%4==3) sg[x] = x+1. 打表代码: #include<iostream> #include<cstdio> #…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4678 题意就不说了,太长了... 这个应该算简单博弈吧.先求联通分量,把空白区域边上的数字个数全部求出来a[i](就是一个连通分量),然后就是n堆石子,每堆每次可以取一个或者全部取掉,然后要注意在取玩边上的石子后,剩下的就只能一次取掉了,因此我们直接把空白区域上的算做一个a[i]+1.然后这个SG函数很好求,奇数是1,偶数是2... //STATUS:C++_AC_156MS_4268KB #inc…
题目地址:light oj 1007 第一发欧拉函数. 欧拉函数重要性质: 设a为N的质因数.若(N % a == 0 && (N / a) % a == 0) 则有E(N)=E(N / a) * a:若(N % a == 0 && (N / a) % a != 0) 则有:E(N) = E(N / a) * (a - 1) 对于这题来说.首先卡MLE.. 仅仅能开一个数组..所以把前缀和也存到欧拉数组里. 然后卡long long. .要用unsigned long lo…
此文为以下博客做的摘要: https://blog.csdn.net/strangedbly/article/details/51137432 ---------------------------------------------------------------------------------------- 1.定义P-position和N-positon P表示Previous,N表示Next. 即上一个移动的人有必胜策略的局面是P-position,“先手必败”或“后手必胜”,现…