HDU2176尼姆博弈
HDU2176 http://acm.hdu.edu.cn/showproblem.php?pid=2176

假设有3个数,a[0],a[1],a[2];那么ans=a[0]^a[1]^a[2];若ans^a[0]=s;
那么a[1]^a[2]^s=a[1]^a[2]^ans^a[0]=a[1]^a[2]^a[0]^a[1]^a[2]^a[0]=0(根据异或的性质)。
上代码:
#include<stdio.h>
#include<iostream>
#include<string.h>
using namespace std;
int main()
{
int m,n;
int a[];
int ans=;
while(~scanf("%d",&n)&&n){
for(int i=;i<n;i++){
cin>>a[i];
ans^=a[i];
}
if(ans==)
cout<<"No"<<endl;
else {cout<<"Yes"<<endl;
for(int i=;i<n;i++){
int s=ans^a[i];
if(s<=a[i])
cout<<a[i]<<" "<<s<<endl;
}
}
}
}
HDU2176尼姆博弈的更多相关文章
- hdu2176 尼姆博弈
如果 a1^a2^a3........^an=0,必败态. 如果 a1^a2^a3........^an!=0,必胜态. 对于必胜态,若a1^a2^a3........^an=k,要让对方为必败态,所 ...
- hdu----(1849)Rabbit and Grass(简单的尼姆博弈)
Rabbit and Grass Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) ...
- hdu 1849(Rabbit and Grass) 尼姆博弈
Rabbit and Grass Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) ...
- Being a Good Boy in Spring Festival 尼姆博弈
Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Submit Status Descr ...
- HDU 4315 Climbing the Hill (阶梯博弈转尼姆博弈)
Climbing the Hill Time Limit: 1000MS Memory Limit: 32768KB 64bit IO Format: %I64d & %I64u Su ...
- Light OJ 1393 Crazy Calendar (尼姆博弈)
C - Crazy Calendar Time Limit:4000MS Memory Limit:32768KB 64bit IO Format:%lld & %llu Su ...
- LightOJ 1247 Matrix Game (尼姆博弈)
A - Matrix Game Time Limit:2000MS Memory Limit:32768KB 64bit IO Format:%lld & %llu Submi ...
- Light OJ 1253 Misere Nim (尼姆博弈(2))
LightOJ1253 :Misere Nim 时间限制:1000MS 内存限制:32768KByte 64位IO格式:%lld & %llu 描述 Alice and Bob ar ...
- hdu-------(1848)Fibonacci again and again(sg函数版的尼姆博弈)
Fibonacci again and again Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Jav ...
随机推荐
- HackerRank "Favorite sequence"
Typical topological sorting problem .. why is it 'difficult'? #include <iostream> #include < ...
- Redis在Windows环境下搭建
1. 下载Redis-Windows版本 Redis官网下载页面: http://redis.io/download Windows下Redis项目: https://github.com/MSOp ...
- Linux的软连接与硬链接
Linux的软连接相当于window系统的快捷方式,如我们桌面的QQ等. 硬连接相当于复制一个文件,但不同的是两个文件内容同步.如创建一个文件A的硬连接B, 如果我修改A里面的内容,同时B中的内容也会 ...
- PHP 正则表达式常用函数使用小结
在PHP中有两套正则表达式函数库.一套是由PCRE(Perl Compatible Regular Expression)库提供的.PCRE库使用和Perl相同的语法规则实现了正则表达式的模式匹配,其 ...
- [Bug-IOS] - linker command failed with exit code 1 (use -v to see invocation)
Ld /Users/Rubert/Library/Developer/Xcode/DerivedData/OC_Language-emftyzftyvhdpuaxipddjmpnpvox/Build/ ...
- Flink on Yarn运行机制
从图中可以看出,Yarn的客户端需要获取hadoop的配置信息,连接Yarn的ResourceManager.所以要有设置有 YARN_CONF_DIR或者HADOOP_CONF_DIR或者HADOO ...
- 用CRT connect MongoDB 使用Backspace无效
这是个很蛋疼的小问题... 使用./mongo 10.1.235.62:27017 连接上后 打错了无法删除!? 这是在逗我,那就修改CRT个设置,点击选项,会话选项,仿真,把终端改成Linux就行了 ...
- PLSQL_Oracle Lock锁的处理(案例)
2014-06-21 Created By BaoXinjian
- NeHe OpenGL教程 第三十二课:拾取游戏
转自[翻译]NeHe OpenGL 教程 前言 声明,此 NeHe OpenGL教程系列文章由51博客yarin翻译(2010-08-19),本博客为转载并稍加整理与修改.对NeHe的OpenGL管线 ...
- Java NIO使用及原理分析 (一)
http://blog.csdn.net/wuxianglong/article/details/6604817