poj-2234 Matches Game Nim】的更多相关文章

Description Here is a simple game. In this game, there are several piles of matches and two players. The two player play in turn. In each turn, one can choose a pile and take away arbitrary number of matches from the pile (Of course the number of mat…
Matches Game Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 7567   Accepted: 4327 Description Here is a simple game. In this game, there are several piles of matches and two players. The two player play in turn. In each turn, one can ch…
这道题也是一个博弈论 根据一个性质 对于\( Nim \)游戏,即双方可以任取石子的游戏,\( SG(x) = x \) 所以直接读入后异或起来输出就好了 代码 #include <cstdio> #include <algorithm> #include <cstring> using namespace std; int m; int main(){ while(scanf("%d",&m)!=EOF){ ,mid; ;i<=m;i…
题目链接: https://cn.vjudge.net/problem/POJ-2234 题目描述: Here is a simple game. In this game, there are several piles of matches and two players. The two player play in turn. In each turn, one can choose a pile and take away arbitrary number of matches fro…
传送门 #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> using namespace std; int main() { int n; while(~scanf("%d",&n)) { ; ;i<n;i++) { scanf("%d",&a); res^=a; } if(!res)//T prin…
题目大意:尼姆博弈,判断是否先手必胜. 题目思路: 尼姆博弈:有n堆各a[]个物品,两个人轮流从某一堆取任意多的物品,规定每次至少取一个,多者不限,最后取光者得胜. 获胜规则:ans=(a[1]^a[2] --^a[n]),若ans==0则后手必胜,否则先手必胜. #include<iostream> #include<algorithm> #include<cstring> #include<vector> #include<stdio.h>…
http://poj.org/problem?id=2234 博弈论真是博大精深orz 首先我们仔细分析很容易分析出来,当只有一堆的时候,先手必胜:两堆并且相同的时候,先手必败,反之必胜. 根据博弈论的知识(论文 张一飞:<由感性认识到理性认识——透析一类搏弈游戏的解答过程>) 局面可以分解,且结果可以合并. 局面均是先手 当子局面是 胜 和 败,那么局面则为胜 当子局面是 败 和 胜,那么局面则为胜 当子局面是 败 和 败,那么局面则为败 当子局面为 胜 和 胜,那么局面为不确定 而这些性质…
思路: nim博弈裸题 xor一下 //By SiriusRen #include <cstdio> using namespace std; int n,tmp,xx; int main(){ while(~scanf("%d",&n)){ tmp=0; while(n--)scanf("%d",&xx),tmp^=xx; puts(!tmp?"No":"Yes"); } }…
Matches Game Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 13264   Accepted: 7712 Description Here is a simple game. In this game, there are several piles of matches and two players. The two player play in turn. In each turn, one can c…
#include<iostream> #include<stdio.h> #include<algorithm> #define MAXN 100 using namespace std; //把所有堆的石子数目用二进制数表示出来,当全部这些数按位异或结果为0时当前局面为必败局面,否则为必胜局面: int a[MAXN]; void op(int & num); int trans_10_to_2(int num); int main() { //freopen…