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尼姆博弈的更多相关文章

  1. hdu2176 尼姆博弈

    如果 a1^a2^a3........^an=0,必败态. 如果 a1^a2^a3........^an!=0,必胜态. 对于必胜态,若a1^a2^a3........^an=k,要让对方为必败态,所 ...

  2. hdu----(1849)Rabbit and Grass(简单的尼姆博弈)

    Rabbit and Grass Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) ...

  3. hdu 1849(Rabbit and Grass) 尼姆博弈

    Rabbit and Grass Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) ...

  4. Being a Good Boy in Spring Festival 尼姆博弈

    Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status Descr ...

  5. HDU 4315 Climbing the Hill (阶梯博弈转尼姆博弈)

    Climbing the Hill Time Limit: 1000MS   Memory Limit: 32768KB   64bit IO Format: %I64d & %I64u Su ...

  6. Light OJ 1393 Crazy Calendar (尼姆博弈)

    C - Crazy Calendar Time Limit:4000MS     Memory Limit:32768KB     64bit IO Format:%lld & %llu Su ...

  7. LightOJ 1247 Matrix Game (尼姆博弈)

    A - Matrix Game Time Limit:2000MS     Memory Limit:32768KB     64bit IO Format:%lld & %llu Submi ...

  8. Light OJ 1253 Misere Nim (尼姆博弈(2))

    LightOJ1253 :Misere Nim 时间限制:1000MS    内存限制:32768KByte   64位IO格式:%lld & %llu 描述 Alice and Bob ar ...

  9. hdu-------(1848)Fibonacci again and again(sg函数版的尼姆博弈)

    Fibonacci again and again Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Jav ...

随机推荐

  1. js,jquery概念理解

    js,jquery都是一种脚本语言,编写代码,实现页面的dom操作,特效等功能. 区别: 1.jquery"写的更少,做的更多"; 2.使用jquery需要导入jquery文件. ...

  2. EnterpriseLibrary之Caching应用

    http://blog.csdn.net/linux7985/article/details/6239433 http://cache.baiducontent.com/c?m=9f65cb4a8c8 ...

  3. .NET,Cookie,写Cookie,取Cookie

    Cookie是一段文本信息,在客户端存储 Cookie 是 ASP.NET 的会话状态将请求与会话关联的方法之一.Cookie 也可以直接用于在请求之间保持数据,但数据随后将存储在客户端并随每个请求一 ...

  4. .NET(C#)生成条形码

    using System; using System.Data; using System.Configuration; using System.Web; using System.Web.Secu ...

  5. Angular学习(3)- 双向梆定

    示例代码: <!DOCTYPE html> <html ng-app="MyApp"> <head> <title>Study 3& ...

  6. 【linux】who&&w

    who和w 看到目前服务器所登陆的用户,区别是w能看到更详细的信息. [root@andon tmp]# who admin tty5[tty指本地登陆] 2016-05-27 15:16[登陆时间] ...

  7. android学习笔记13——ExpandableListView

    ExpandableListView==>可展开的列表组件 ==> ExpandableListView是ListView的子类,对其进行了扩展,其将应用中的列表项分为几组,每组中又包含多 ...

  8. PLSQL_性能优化系列07_Oracle Parse Bind Variables解析绑定变量

    2014-09-25 Created By BaoXinjian

  9. HTML 表单验证和事件

    1.表单验证<form></form> (1).非空验证(去空格) (2).对比验证(跟一个值对比) (3).范围验证(根据一个范围进行判断) (4).固定格式验证:电话号码, ...

  10. activity属性_ _activity 属性说明

    activity是android中使用非常平凡的一种组件,我们除了需要掌握activity中的生命周期以外,还需要掌握activity中的其 他设置. 1.activity 中主题的设置   andr ...