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

参见上一篇博客,里面有分析和结论. #include <cstdio> int main() { int T; scanf("%d", &T); while(T--) { , xorsum = ;//c为充裕堆的个数 scanf("%d", &n); ) c++; } ) || (xorsum && !c)) puts("Brother");//T2和S0状态必败 else puts("Joh…
John Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others) Total Submission(s): 6017    Accepted Submission(s): 3499 Problem Description Little John is playing very funny game with his younger brother. There is one big b…
1.HDU 1907 2.题意:n堆糖,两人轮流,每次从任意一堆中至少取一个,最后取光者输. 3.总结:有点变形的Nim,还是不太明白,盗用一下学长的分析吧 传送门 分析:经典的Nim博弈的一点变形.设糖果数为1的叫孤独堆,糖果数大于1的叫充裕堆,设状态S0:a1^a2^..an!=0&&充裕堆=0,则先手必败(奇数个为1的堆,先手必败).S1:充裕堆=1,则先手必胜(若剩下的n-1个孤独堆个数为奇数个,那么将那个充裕堆全部拿掉,否则将那个充裕堆拿得只剩一个,这样的话先手必胜).T0:a1…
S-Nim HDU 1536 博弈 sg函数 题意 首先输入K,表示一个集合的大小,之后输入集合,表示对于这对石子只能去这个集合中的元素的个数,之后输入 一个m表示接下来对于这个集合要进行m次询问,之后m行,每行输入一个n表示有n个堆,每堆有n1个石子,问这一行所表示的状态是赢还是输,如果赢输入W否则L. 解题思路 如果没有每次取石子个数的限制的话,那么仅仅需要把每堆石子的个数进行异或运算即可,如果结果不是1,那么先手赢,反之后手赢. 但是这里对每次取石子的个数进行了限制,每次只能从几个数中进行…
题目链接: 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…
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. 结论:当石子数量…
题目 参考了博客: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堆的糖,一种情况下是每堆都是…
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…
传送门 #include<iostream> #include<cstdio> #include<cstring> using namespace std; int main() { int t; scanf("%d",&t); while(t--) { ; ,g=;//¹Âµ¥¶Ñ¡¢³äÔ£¶Ñ scanf("%d",&n); ;i<n;i++) { scanf("%d",&a…