POJ 2234 Matches Game(直接的NIM)
2013-07-31 20:57
211 查看
//简单直接的博弈论问题,两个人分别取n堆石子,谁取到最后一颗谁赢,SG(x)=x,直接异或即可 #include<stdio.h> #define maxn 20+10 int m; long number[maxn]; int find_sg(int x)//SG函数 { return x; } int main() { while(scanf("%d",&m)!=EOF) { for(int i=1;i<=m;i++) scanf("%ld",&number[i]); int ans; if(m==1) ans=1; else { ans=find_sg(number[1])^find_sg(number[2]); for(int i=3;i<=m;i++) ans=ans^find_sg(number[i]); } if(ans==0)//若异或值为0,先手必败 printf("No\n"); else printf("Yes\n"); } return 0; }
相关文章推荐
- 【 数论 Nim博弈 】POJ 2234 Matches Game
- POJ 2234 Matches Game (经典Nim博弈)
- POJ - 2234 Matches Game【Nim博弈】
- POJ 2234 Matches Game (nim博弈裸题)
- POJ 2234 Matches Game 博弈论水题 Nim模型
- POJ 2234 Matches Game(Nim博弈裸题)
- POJ 2234 Matches Game (尼姆博弈)
- poj--2234--Matches Game(尼姆博弈)
- POJ 2234 Matches Game 笔记
- poj--2234--Matches Game(尼姆博弈)
- poj 2234 Matches Game (博弈)
- poj 2234 Matches Game
- Matches Game(POJ_2234)
- poj2234--Matches Game
- poj 2234 博弈论Nim取子游戏
- poj2234 Matches Game
- 【poj 2234】Matches Game
- POJ 2234 Matches Game
- POJ 2234 Matches Game
- POJ 2234-Matches Game(博弈)