如果 a1^a2^a3........^an=0,必败态。

如果 a1^a2^a3........^an!=0,必胜态。

对于必胜态,若a1^a2^a3........^an=k,要让对方为必败态,所以一定存在数,他的2进制有k的最高位上的1,使对方为必败态;

所以如果k^a[i]<a[i],一定是从该数中取,a[i]-k^a[i]个。

如果剩下一堆物品:必胜;

如果剩下二堆,都为1,必输;

如果剩下二堆,一堆为1,另一堆为n,必胜;

#include<stdio.h>
#include<string.h>
#define maxn 200010
int main()
{
int i,j,a[maxn],n;
while(scanf("%d",&n)!=EOF)
{
if(!n)break;
int flag;
flag=;
for(i=;i<n;i++)
{
scanf("%d",&a[i]);
flag^=a[i];
}
if(flag==)
printf("No\n");
else
{
printf("Yes\n");
for(i=;i<n;i++)
{
if((flag^a[i]) < a[i])
{
printf("%d %d\n",a[i],flag^a[i]);
}
}
}
}
}

hdu2176 尼姆博弈的更多相关文章

  1. 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];若a ...

  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. css3之属性选择器

    总体来看一下都有哪些选择器 1.属性选择器  1)[att*=val] 2)[att^=val] 3)[att$=val] 2.结构伪类选择器 3.UI伪类选择器 其中E:read-only伪类选择器 ...

  2. Html-前端表单校验

    先前端校验再跳转action <form action="/hr/kefu/edit_dangan_do.html" method="post" enct ...

  3. url映射 ccf (Java正则表达式80分解法)

    问题描述 试题编号: 201803-3 试题名称: URL映射 时间限制: 1.0s 内存限制: 256.0MB 问题描述: 问题描述 URL 映射是诸如 Django.Ruby on Rails 等 ...

  4. org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.hs.model.StudentModel]: No default constructor found; nested exception is java.lang.NoSuchMethodException: c

    root cause org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [c ...

  5. Win7。56个进程让我头疼

    乱七八糟的进程一个一个往外蹦,如此痛苦. 安装了一个VM9,进程数量+5,安装了卖咖啡的,进程数量+5. 除去这10个,系统进程数量还有46个....还是太多... 64位系统,真的很痛苦,还没有怎么 ...

  6. java-File类-字节流

    一 File 1.1 递归子目录 获取所有子目录中的内容 import java.io.File; public class GetAllFiles { /** * @param args */ pu ...

  7. JavaScript 对象的所有方法名称转换为大写

    function A() { this.do1 = function () { console.log(1); }; this.do2 = function () { console.log(2); ...

  8. Python实例 复制文件

    import  shutil import  os import  os.path src = " d:\\download\\test\\myfile1.txt " dst = ...

  9. Python 数据文件操作——写出数据

  10. golang之switch