John(博弈)】的更多相关文章

Little John is playing very funny game with his younger brother. There is one big box filled with M&Ms of different colors. At first John has to eat several M&Ms of the same color. Then his opponent has to make a turn. And so on. Please note that…
Nim游戏:有n堆石子,每堆个数不一,两人依次捡石子,每次只能从一堆中至少捡一个.捡走最后一个石子胜. 先手胜负:将所有堆的石子数进行异或(xor),最后值为0则先手输,否则先手胜. ================================ Anti-Nim游戏:游戏与Nim游戏基本相同,只是捡走最后一个石子者输. 先手胜负:将所有堆的石子数进行异或(xor),如果异或结果为0且所有堆的石子数全为1,或者异或结果为0且存在数量大于1的石子堆,则先手胜.否则先手输. 该题即是Anti-Ni…
Description Little John is playing very funny game with his  younger brother. There  is one big box filled  with M&Ms of different colors. At first John has to eat several M&Ms of the same color. Then his  opponent has to make a turn. And so on. P…
Problem Description Little John is playing very funny game with his younger brother. There is one big box filled with M&Ms of different colors. At first John has to eat several M&Ms of the same color. Then his opponent has to make a turn. And so o…
思路: 注意与Nimm博弈的区别,谁拿完谁输! 先手必胜的条件: 1.  每一个小游戏都只剩一个石子了,且SG = 0. 2. 至少有一堆石子数大于1,且SG不等于0 证明:1. 你和对手都只有一种选择,随便怎么拿,你都赢了 2.  a:如果只有一堆石子数量大于1,那么你赢了,你可以拿完使得整个游戏的1的数量不变,剩余1个整个游戏1的数量增加. b:如果至少有两堆石子数大于1,那么你可以让SG变为0,令对手处于P态,并且当前至少有两堆数量大于1,对手无论怎么拿SG都会变成非0. 结论:当石子数量…
题意:n堆石头,拿走最后一块的输 思路:SJ定理:先手必胜当且仅当:(1)游戏的SG函数不为0且游戏中某个单一游戏的SG函数大于1:(2)游戏的SG函数为0且游戏中没有单一游戏的SG函数大于1. 参考:[博弈]Anti,Multi,Every-SG 代码: #include<set> #include<map> #include<stack> #include<cmath> #include<queue> #include<vector&g…
题目链接: PKU:http://poj.org/problem? id=3480 HDU:http://acm.hdu.edu.cn/showproblem.php? pid=1907 Description Little John is playing very funny game with his younger brother. There is one big box filled with M&Ms of different colors. At first John has to…
题目 参考了博客:http://blog.csdn.net/akof1314/article/details/4447709 //0 1 -2 //1 1 -1 //0 2 -1 //1 2 -1 //2 2 -2 //0 3 -1 //1 3 -1 //2 3 -1 //3 3 -2 //0 4 -1 //1 4 -1 //2 4 -1 //3 4 -1 //4 4 -2 //0 5 -1 //1 5 -1 //2 5 -1 //3 5 -1 /* 尼姆博弈.对于N堆的糖,一种情况下是每堆都是…
1022: [SHOI2008]小约翰的游戏John 题目:传送门 题目大意: 一道反nim游戏,即给出n堆石子,每次可以取完任意一堆或一堆中的若干个(至少取1),最后一个取的LOSE  题解: 一道很不错的题目啊,感觉可以作为一道很好的入门题 读前一戳:博弈论文 && POPQQQ大佬%%% 大体要分为三种情况来讨论: 1.全是为1的石子堆,如有偶数堆则先手胜,反之后手胜 2.有两堆相同的石子且都不为1(后手获胜的几率很大):     那么如果先手将其中一堆取剩1,那么后手就可以将另一堆…
John Problem Description   Little John is playing very funny game with his younger brother. There is one big box filled with M&Ms of different colors. At first John has to eat several M&Ms of the same color. Then his opponent has to make a turn. A…