现在的位置: 首页 > 综合 > 正文

hdu 2176 nim和

2013年10月12日 ⁄ 综合 ⁄ 共 379字 ⁄ 字号 评论关闭
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int a[200011];
int main()
{
    int m,nim,i;
   // bool flag;
    while(scanf("%d",&m)!=EOF && m)
    {
        scanf("%d",&a[0]);
        nim=a[0];
        for(i=1;i<m;i++)
        {
            scanf("%d",&a[i]);
            nim^=a[i];
        }
        if(nim)
            printf("YES\n");
        else
        {
            printf("NO\n");
            continue;
        }
        for(i=0;i<m;i++)
        {
            int temp=nim;
            temp^=a[i];
            if(temp<=a[i])
                    printf("%d %d\n",a[i],temp);
        }
       // printf("\n");
    }
    return 0;
}

抱歉!评论已关闭.