HDU 2176 取(m堆)石子游戏(尼姆博奕)

时间:2022-04-05 07:52:18

nim基础博弈

#include<stdio.h>
#include<iostream>
#include<cstring>
#include<queue>
using namespace std;
int main()
{
int n,a[];
while(~scanf("%d",&n) && n)
{
int ans = ;
for(int i = ;i < n;i++)
{
scanf("%d",&a[i]);
ans ^= a[i];
}
if(ans == )
puts("No");
else
{
puts("Yes");
for(int i = ;i < n;i++)
{
if(a[i] >= (ans^a[i]))
printf("%d %d\n",a[i],ans^a[i]);
}
}
}
}