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 ...
随机推荐
- 【python】python异常类型
python2: BaseException +-- SystemExit +-- KeyboardInterrupt +-- GeneratorExit +-- Exception +-- Stop ...
- 线性判别分析(Linear Discriminant Analysis)转载
1. 问题 之前我们讨论的PCA.ICA也好,对样本数据来言,可以是没有类别标签y的.回想我们做回归时,如果特征太多,那么会产生不相关特征引入.过度拟合等问题.我们可以使用PCA来降维,但PCA没有将 ...
- SQLite介绍、学习笔记、性能测试
SQLite介绍.学习笔记.性能测试 哪些人,哪些公司或软件在用SQLite: Nokia's Symbian,Mozilla,Abobe,Google,阿里旺旺,飞信,Chrome,FireFox可 ...
- define宏定义中的#,##,@#及\符号
define宏定义中的#,##,@#及\符号 在#define中,标准只定义了#和##两种操作.#用来把参数转换成字符串,##则用来连接两个前后两个参数,把它们变成一个字符串. 1.# (string ...
- memcached简介(转)
背景 memcached是一个高性能.分布式的内存对象缓存系统. memcached广泛应用在大负载高并发的网站上,是一种非常成熟的产品(称为一项技术也未尝不可).像facebook,yout ...
- iphone Dev 开发实例10:How To Add a Slide-out Sidebar Menu in Your Apps
Creating the Xcode Project With a basic idea about what we’ll build, let’s move on. You can create t ...
- [JS]Javascript的this用法
转自:阮一峰 this是Javascript语言的一个关键字. 它代表函数运行时,自动生成的一个内部对象,只能在函数内部使用.比如, function test(){ this.x = 1; } 随着 ...
- apache 做http代理
1.修改 http.conf 文件 ,增加 监听端口 Listen 开启需要的扩展 LoadModule proxy_module modules/mod_proxy.so LoadModule pr ...
- Linux命令(20)linux服务器之间复制文件和目录
linux的scp命令: scp就是secure copy的简写,用于在linux下进行远程拷贝文件的命令,和它类似的命令有cp,不过cp只是在本机进行拷贝不能跨服务器. 有时我们需要获得远程服务器上 ...
- 关于gcd函数解最大公约数
数学知识:由于两个数的乘积等于这两个数的最大公约数与最小公倍数的积.即(a,b)×[a,b]=a×b.所以,求两个数的最小公倍数,就可以先求出它们的最大公约数,然后用上述公式求出它们的最小公倍数.例如 ...