Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. #define ll long long
  3. #define rep(i,a,b) for(ll i=a;i<=b;i++)
  4. #define ios ios_base::sync_with_stdio(false); cin.tie(NULL);
  5. using namespace std;
  6.  
  7. ll t1,t2,t3;
  8.  
  9.  
  10. int main(){
  11. ll TESTS=1;
  12. //cin>>TESTS;
  13. while(TESTS--){
  14. ll n,x;
  15. cin>>n>>x;
  16. if(n==1 && x==1){
  17. cout<<0;
  18. return 0;
  19. }
  20. set<ll> s;
  21. rep(i,1,pow(2,n)-1){
  22. if(i==x){
  23. continue;
  24. }
  25. ll b=i^x;
  26. s.insert(min(i,b));
  27. }
  28. vector<ll> v;
  29. for(auto i:s){
  30. v.push_back(i);
  31. }
  32. for(ll i=v.size()-1;i>0;i--){
  33. v[i]^=v[i-1];
  34. }
  35. cout<<v.size()<<endl;
  36. for(auto i:v){
  37. cout<<i<<" ";
  38. }
  39. }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement