博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Codeforces 862C 异或!
阅读量:5063 次
发布时间:2019-06-12

本文共 1658 字,大约阅读时间需要 5 分钟。

Description

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 10^6.

Input

The only line contains two integers n and x (1 ≤ n ≤ 10^5, 0 ≤ x ≤ 10^5) — 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.

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

You can read more about the bitwise-xor operation here: 

For the first sample .

For the second sample .

 

#include 
#include
#include
#include
#include
#include
using namespace std;int main(){ int a=1<<19,b=1<<18,n,x; cin>>n>>x; if(n==1) printf("Yes\n%d\n",x); else if(n==2) { if(x!=0) printf("Yes\n0 %d\n",x); else printf("No\n"); } else { int ans=0; printf("Yes\n"); for(int i=1;i<=n-3;++i) { printf("%d ",i); ans^=i; } printf("%d %d ",a,b); printf("%d",ans^a^b^x); } return 0;}

 

 

 

转载于:https://www.cnblogs.com/greenaway07/p/10420298.html

你可能感兴趣的文章
Jquery ui widget开发
查看>>
更改git仓库地址
查看>>
有标号DAG计数 [容斥原理 子集反演 组合数学 fft]
查看>>
Recipe 1.4. Reversing a String by Words or Characters
查看>>
Rule 1: Make Fewer HTTP Requests(Chapter 1 of High performance Web Sites)
查看>>
sql注入
查看>>
「破解」Xposed强
查看>>
src与href的区别
查看>>
ABAP工作区,内表,标题行的定义和区别
查看>>
《xxx重大需求征集系统的》可用性和可修改性战术分析
查看>>
Python 中 创建类方法为什么要加self
查看>>
关于indexOf的使用
查看>>
【转】JS生成 UUID的四种方法
查看>>
英语单词
查看>>
centos6.8下安装matlab2009(图片转帖)
查看>>
Mongo自动备份
查看>>
求助大神!怎样批量删除数据库表中某个字段中同样的一段字符!
查看>>
VMWARE虚拟机无法访问的三种方法分析
查看>>
enq: SQ - contention
查看>>
cer证书签名验证
查看>>