HDU 1848 SG函数博弈】的更多相关文章

Fibonacci again and again Problem Description   任何一个大学生对菲波那契数列(Fibonacci numbers)应该都不会陌生,它是这样定义的:F(1)=1;F(2)=2;F(n)=F(n-1)+F(n-2)(n>=3);所以,1,2,3,5,8,13……就是菲波那契数列.在HDOJ上有不少相关的题目,比如1005 Fibonacci again就是曾经的浙江省赛题.今天,又一个关于Fibonacci的题目出现了,它是一个小游戏,定义如下:1. …
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;…
Good Luck in CET-4 Everybody! Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 8634    Accepted Submission(s): 5587 Problem Description 大 学英语四级考试就要来临了,你是不是在紧张的复习?也许紧张得连短学期的ACM都没工夫练习了,反正我知道的Kiki和C…
SG函数: 给定一个有向无环图和一个起始顶点上的一枚棋子,两名选手交替的将这枚棋子沿有向边进行移动,无法移 动者判负.事实上,这个游戏可以认为是所有Impartial Combinatorial Games的抽象模型.也就是说,任何一个ICG都可以通过把每个局面看成一个顶点,对每个局面和它的子局面连一条有向边来抽象成这个“有向图游戏”.下 面我们就在有向无环图的顶点上定义Sprague-Garundy函数.首先定义mex(minimal excludant)运算,这是施加于一个集合的运算,表示最…
kiki's game Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 40000/1000 K (Java/Others) Total Submission(s): 4972    Accepted Submission(s): 2908 Problem Description Recently kiki has nothing to do. While she is bored, an idea appears in his m…
关于SG函数的博弈 首先定义必败态 x : SG[x]=0 设任意一个状态y,到所有y能到达的状态连一条边,令这些后继为z y : SG[y]=mex(SG[z]) SG[y]==0 : y就是必败态 SG[y]!=0 : y就是必胜态 所以博弈时把状态转换成有向图即可 那么n个有向图的情况 SG=SG[1]^SG[2]...^SG[n],即把所有SG异或起来即可 本题就是SG函数的应用:首先三个必败态2*2,2*3,3*2,然后将纸片切成两张等价于两个SG函数的异或 #include<iost…
S-Nim Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 7262    Accepted Submission(s): 3074 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…
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…
对于SG函数来说,sg[y]=x的意义为,x与y的输赢状态是相同的 sg[y]=mex(y)的定义与n.p点的定义是相同的 #include<iostream>#include<cstring>using namespace std;int SG[1001],f[20]={1,2};int flag[20];void getfibo(){    int i;    for(i=2;i<=15;i++) f[i]=f[i-1]+f[i-2];}void getSG(int x)…