hdu 1536 S-Nim(sg函数模板)】的更多相关文章

转载自:http://blog.csdn.net/sr_19930829/article/details/23446173 解题思路: 这个题折腾了两三天,参考了两个模板,在这之间折腾过来折腾过去,终于把用法和需要注意的地方弄清楚了,汗.注意的是: bool类型的数组比int类型的数组快,不超时与超时的区别,在sg组合博弈时,只能在(a1,a2,a3,a4)中取,要特别注意这里面的数字是否是有序的,这个特别重要,下面贴出的两个模板对应了两种情况.最后,大数据输入还得用scanf.. 模板1(该模…
S-Nim Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 4770    Accepted Submission(s): 2058 Problem Description Arthur and his sister Caroll have been playing a game called Nim for some time now.…
S-Nim Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 3077    Accepted Submission(s): 1361 Problem Description Arthur and his sister Caroll have been playing a game called Nim for some time now…
Nim or not Nim? Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1056    Accepted Submission(s): 523 Problem Description Nim is a two-player mathematic game of strategy in which players take turn…
Nim or not Nim? Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status Practice HDU 3032 Description Nim is a two-player mathematic game of strategy in which players take turns removing objects from distinct heaps.…
Problem Description 大学英语四级考试就要来临了,你是不是在紧张的复习?也许紧张得连短学期的ACM都没工夫练习了,反正我知道的Kiki和Cici都是如此.当然,作为在考场浸润了十几载的当代大学生,Kiki和Cici更懂得考前的放松,所谓“张弛有道”就是这个意思.这不,Kiki和Cici在每天晚上休息之前都要玩一会儿扑克牌以放松神经.“升级”?“双扣”?“红五”?还是“斗地主”?当然都不是!那多俗啊~作为计算机学院的学生,Kiki和Cici打牌的时候可没忘记专业,她们打牌的规则是…
S-Nim Time Limit: 1000MS   Memory Limit: 32768KB   64bit IO Format: %I64d & %I64u Submit Status Description Arthur and his sister Caroll have been playing a game called Nim for some time now. Nim is played as follows: The starting position has a numb…
ps:sg[i]为0表示i节点先手必败. 首先定义mex(minimal excludant)运算,这是施加于一个集合的运算,表示最小的不属于这个集合的非负整数.例如mex{0,1,2,4}=3.mex{2,3,5}=0.mex{}=0. 对于一个给定的有向无环图,定义关于图的每个顶点的Sprague-Grundy函数g如下:g(x)=mex{ g(y) | y是x的后继 },这里的g(x)即sg[x] 例如:取石子问题,有1堆n个的石子,每次只能取{1,3,4}个石子,先取完石子者胜利,那么各…
http://acm.split.hdu.edu.cn/showproblem.php?pid=5724 题意: 现在有一个n*20的棋盘,上面有一些棋子,双方每次可以选择一个棋子把它移动到其右边第一个空位置处,谁不能移动了谁就输. 思路: 找规律好像找不着,那么就考虑SG函数了,因为一共只有20列,所以可以状态压缩处理,这样就可以方便的得到某个状态的后继状态. #include<iostream> #include<algorithm> #include<cstring&g…
Chess Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 2605    Accepted Submission(s): 1092 Problem Description Alice and Bob are playing a special chess game on an n × 20 chessboard. There are s…