C. Mahmoud and Ehab and the xor

Mahmoud and Ehab are on the third stage of their adventures now. As you know, Dr. Evil likes sets. This time he won't show them any set from his large collection, but will ask them to create a new set to replenish his beautiful collection of sets.

Dr. Evil has his favorite evil integer x. He asks Mahmoud and Ehab to find a set of n distinct non-negative integers such the bitwise-xor sum of the integers in it is exactly x. Dr. Evil doesn't like big numbers, so any number in the set shouldn't be greater than 106.

Input

The only line contains two integers n and x (1 ≤ n ≤ 105, 0 ≤ x ≤ 105) — the number of elements in the set and the desired bitwise-xor, respectively.

Output

If there is no such set, print "NO" (without quotes).

Otherwise, on the first line print "YES" (without quotes) and on the second line print n distinct integers, denoting the elements in the set is any order. If there are multiple solutions you can print any of them.

Examples
Input
5 5
Output
YES
1 2 4 5 7
Input
3 6
Output
YES
1 2 5
Note

You can read more about the bitwise-xor operation here: https://en.wikipedia.org/wiki/Bitwise_operation#XOR

For the first sample .

For the second sample .

n个不同元素的异或值为x,只有一种情况下为NO,n=2,x=0;剩下的都可以找到。

#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <cassert>
#include <ctime>
#include <map>
#include <set>
using namespace std;
#pragma comment(linker, "/STACK:1024000000,1024000000")
#define lowbit(x) (x&(-x))
#define max(x,y) (x>=y?x:y)
#define min(x,y) (x<=y?x:y)
#define MAX 100000000000000000
#define MOD 1000000007
#define pi acos(-1.0)
#define ei exp(1)
#define PI 3.141592653589793238462
#define ios() ios::sync_with_stdio(true)
#define INF 1044266558
#define mem(a) (memset(a,0,sizeof(a)))
typedef long long ll;
int n,x;
int main()
{
scanf("%d%d",&n,&x);
if(n==) return *printf("YES\n%d\n",x);
else if(n== && x==) return *printf("NO\n");
else if(n== && x)return *printf("YES \n0 %d\n",x);
printf("YES\n");
for(int i=;i<=n-;i++)
{
printf("%d ",i);
x^=i;
}
printf("%d %d %d\n",<<,<<,(<<)^(<<)^x);
}

Coderfroces 862 C. Mahmoud and Ehab and the xor的更多相关文章

  1. Coderfroces 862 B . Mahmoud and Ehab and the bipartiteness

     Mahmoud and Ehab and the bipartiteness Mahmoud and Ehab continue their adventures! As everybody in ...

  2. codeforces 862 C. Mahmoud and Ehab and the xor(构造)

    题目链接:http://codeforces.com/contest/862/problem/C 题解:一道简单的构造题,一般构造题差不多都考自己脑补,脑洞一开就过了 由于数据x只有1e5,但是要求是 ...

  3. Codeforces 862C - Mahmoud and Ehab and the xor

    862C - Mahmoud and Ehab and the xor 思路:找两对异或后等于(1<<17-1)的数(相当于加起来等于1<<17-1),两个再异或一下就变成0了 ...

  4. 862C - Mahmoud and Ehab and the xor(构造)

    原题链接:http://codeforces.com/contest/862/problem/C 题意:给出n,x,求n个不同的数,使这些数的异或和为x 思路:(官方题解)只有n==2&&am ...

  5. CodeForces - 862C Mahmoud and Ehab and the xor(构造)【异或】

    <题目链接> 题目大意: 给出n.m,现在需要你输出任意n个不相同的数(n,m<1e5),使他们的异或结果为m,如果不存在n个不相同的数异或结果为m,则输出"NO" ...

  6. 【构造】【分类讨论】Codeforces Round #435 (Div. 2) C. Mahmoud and Ehab and the xor

    题意:给你n,x,均不超过10^5,让你构造一个无重复元素的n个元素的非负整数集合(每个元素不超过10^6),使得它们的Xor和恰好为x. 如果x不为0: 随便在x里面找一个非零位,然后固定该位为0, ...

  7. 【Codeforces Round #435 (Div. 2) C】Mahmoud and Ehab and the xor

    [链接]h在这里写链接 [题意] 让你组成一个n个数的集合,使得这n个数的异或和为x; x<=1e5 每个数最大1e6; [题解] 1e5<=2^17<=2^18<=1e6的 ...

  8. CodeForces - 862C Mahmoud and Ehab and the xor(构造)

    题意:要求构造一个n个数的序列,要求n个数互不相同,且异或结果为x. 分析: 1.因为0 ^ 1 ^ 2 ^ 3 ^ ... ^ (n - 3) ^ (n - 2) ^ (0 ^ 1 ^ 2 ^ 3 ...

  9. Codeforces 862A Mahmoud and Ehab and the MEX

    传送门:CF-862A A. Mahmoud and Ehab and the MEX time limit per test 2 seconds memory limit per test 256 ...

随机推荐

  1. Linux头文件的设置

    GCC/G++会查找系统默认的include和link的路径,以及自己在编译命令中指定的路径. 1.include头文件路径 除了默认的/usr/include, /usr/local/include ...

  2. mysql死锁-查询锁表进程-分析锁表原因

    查询锁表进程: 1.查询是否锁表 show OPEN TABLES where In_use > 0;   2.查询进程     show processlist   查询到相对应的进程===然 ...

  3. 今天遇到的一个诡异的core和解决 std::sort

    其实昨天开发pds,就碰到了core,我还以为是内存不够的问题,或者其他问题. 今天把所有代码挪到了as这里,没想到又出core了. 根据直觉,我就觉得可能是std::sort这边的问题. 上网一搜, ...

  4. CSS透明度设置支持IE,Chrome,Firefox浏览器

    CSS文件里设置例如以下就可以 filter:alpha(opacity=60); //支持IE opacity:0.6; //支持Chrome.Firefox

  5. Android 流量分析 tcpdump &amp; wireshark

    APP竞争已经白热化了,控制好自己Android应用的流量能够给用户一个良好的用户体验噢,给用户多一个不卸载的理由. Android 怎样进行流量分析?用好tcpdump & wireshar ...

  6. zookeeper的理解与概述

    文章转自https://www.cnblogs.com/likehua/p/3999600.html  感谢博主 文章转自:http://www.aboutyun.com/thread-9266-1- ...

  7. 如何在一个 U 盘上安装多个 Linux 发行版

    作者: Ambarish Kumar 译者: LCTT geekpi 本教程介绍如何在一个 U 盘上安装多个 Linux 发行版.这样,你可以在单个 U 盘上享受多个现场版live Linux 发行版 ...

  8. mongodb 的 curd

        增:          db.表名.insert({name:'lisi',age:24});                                                  ...

  9. blongsTo 用法

    当存在这样两张表的时候: one{ , 'name':"name" 'sex':"sex" } two{ , 'type':json } 当我们需要在调用到 o ...

  10. 20180929 北京大学 人工智能实践:Tensorflow笔记07

    (完)