hdu1536(sg函数)】的更多相关文章

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1536 题意:首先输入K 表示一个集合的大小  之后输入集合 表示对于这对石子只能去这个集合中的元素的个数 之后输入 一个m 表示接下来对于这个集合要进行m次询问 之后m行 每行输入一个n 表示有n个堆  每堆有n1个石子  问这一行所表示的状态是赢还是输 如果赢输入W否则L 思路:sg函数 一开始直接打表tle了,因该是多组输入的原因吧 然后我们再仔细考虑一下这个m,m<=100,一般来说,给的数据…
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…
http://acm.hdu.edu.cn/showproblem.php?pid=1536 给出能够取的方法序列,然后求基本石子堆问题. 只要用S序列去做转移即可. 注意has初始化的一些技巧 #include <iostream> #include <vector> #include <set> #include <cstdlib> #define LL long long using namespace std; ,NM=; int sg[N]; bo…
S-Nim Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 10368    Accepted Submission(s): 4262 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1536 Descripion: Arthur and his sister Caroll have been…
S-Nim Time Limit: 2000MS   Memory Limit: 65536KB   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…
[hdu1536][poj2960]S-Nim 题意 题意就是给出一个数组h,为每次可以取石子的数目. 然后给你n堆石子每堆si.求解先手能不能赢? 分析 根据\(h\)数组预处理出\(sg[i]\)表示\(i\)个石子对应的\(sg\)值. 然后\(sg[s_1]\otimes sg[s_2]\otimes ...\otimes sg[s_n]\)即可. 小结 SG函数的使用,通常是ICG模型上不只存在一个石子. 如果只存在一个,可以简化SG函数,直接用布尔值代替.这样的普适性虽然没这么高,但…
Fibonacci again and again Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 7663    Accepted Submission(s): 3205 Problem Description 任何一个大学生对菲波那契数列(Fibonacci numbers)应该都不会陌生,它是这样定义的:F(1)=1;F(2)=2;…
Sprague-Grundy定理(SG定理): 游戏和的SG函数等于各个游戏SG函数的Nim和.这样就可以将每一个子游戏分而治之,从而简化了问题.而Bouton定理就是Sprague-Grundy定理在Nim游戏中的直接应用,因为单堆的Nim游戏 SG函数满足 SG(x) = x.对博弈不是很清楚的请参照http://www.cnblogs.com/ECJTUACM-873284962/p/6398385.html进行进一步理解. SG函数: 首先定义mex(minimal excludant)…
A Simple Nim Problem Description   Two players take turns picking candies from n heaps,the player who picks the last one will win the game.On each turn they can pick any number of candies which come from the same heap(picking no candy is not allowed)…
转自:http://chensmiles.blog.163.com/blog/static/12146399120104644141326/ http://blog.csdn.net/xiaofengcanyuexj/article/details/17119705 SG函数 “Sprague-Grundy函数” 我们将面对更多与Nim游戏有关的变种,还会看到Nim游戏的a1^a2^...^an这个值更广泛的意义. 上面的文章里我们仔细研究了Nim游戏,并且了解了找出必胜策略的方法.但如果把Ni…