POJ 2234
来源:互联网 发布:深圳大学有网络教育吗 编辑:程序博客网 时间:2024/06/04 01:05
题意:有n堆火柴,每人每次可以从一堆中拿走任意多个,两人轮流操作,谁无子可取谁输。输入n堆火柴各自的数量,输出先手是否能赢。
分析:NP问题,必胜态N(next player wins),必败态P(previous player wins)
分析:NP问题,必胜态N(next player wins),必败态P(previous player wins)
它是一个尼姆博奕的扩展(好像是,有待确认,但很类似,大家可以去看看这个算法)————按位异或
代码:
#include <iostream>#include <stdio.h>using namespace std;int main(){ long long n,a[25],i; while(scanf("%lld",&n)!=EOF) { for(i=0;i<n;i++) scanf("%lld",&a[i]); int s=a[0]; for(i=1;i<n;i++) s^=a[i]; if(s!=0) printf("Yes\n"); else printf("No\n"); } return 0;}
- POJ 2234
- POJ 2234
- poj-2234
- poj 2234
- POJ-2234:Matches Game
- POJ 2234 尼姆博奕
- POJ-2234-Matches Game
- POJ 2234 Nim
- poj 2234 博弈-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
- POJ
- poj
- POJ
- 阶乘因式分解
- How To Shutdown Windows Server 2012
- Linux内核镜像格式
- Mac OS X背后的故事(十)Mac OS X文件系统的来龙去脉(下)
- 【OpenCV入门指南】第十三篇 人脸识别
- POJ 2234
- Cache学习系列一
- 基于MPLAB X IDE配置位设置讲解
- BSTR使用注意事项
- 国外免费的图像库
- openshift空间访问方法
- Android网络编程通信概述【详细版】
- ZenFramework中的View对象初始化流程
- 可扩展认证协议(EAP)4. EAP数据包格式