Advertisement
Guest User

Untitled

a guest
Sep 19th, 2017
2,588
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.52 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. const int pw1=(1<<17);
  6. const int pw2=(1<<18);
  7.  
  8. int main()
  9. {
  10.     int n,x;
  11.     cin >> n >> x;
  12.     if(n==1)
  13.         cout << "YES\n"<<x<<"\n";
  14.     else if(n==2&&x==0)
  15.         cout << "NO\n";
  16.     else if(n==2)
  17.         cout << "YES\n0 "<<x<<"\n";
  18.     else
  19.     {
  20.         int i;
  21.         int ans=0;
  22.         cout << "YES\n";
  23.         for(i=1;i<=n-3;i++)
  24.         {
  25.             cout << i << " ";
  26.             ans^=i;
  27.         }
  28.         if(ans==x)
  29.             cout << pw1+pw2 << " " << pw1 << " " << pw2<< "\n";
  30.         else
  31.             cout << pw1 << " " << ((pw1^x)^ans) << " 0 \n";
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement