标签:long ssis sub xor eof opera i++ title first
Given two integers n and x, construct an array that satisfies the following conditions:
A sequence b is a subsegment of a sequence a if b can be obtained from a by deletion of several (possibly, zero or all) elements from the beginning and several (possibly, zero or all) elements from the end.
The only line contains two integers n and x (1≤n≤18 1≤x<2^18).
The first line should contain the length of the array l.
If l is positive, the second line should contain l space-separated integers a1, a2, ……, al (1≤ai<2^n) — the elements of the array a.
If there are multiple solutions, print any of them.
1 #include<bits/stdc++.h> 2 #include<vector> 3 using namespace std; 4 long long n,x; 5 bool pd[2000010]; 6 int main(){ 7 cin>>n>>x; 8 memset(pd,0,sizeof pd); 9 long long cnm=(1<<n); 10 for (int i=0;i<cnm;i++) 11 if (!pd[i]) 12 pd[i^x]=1; 13 int ans=0; 14 for (int i=1;i<cnm;i++) 15 if (!pd[i]) 16 ans++; 17 cout<<ans<<endl; 18 int l=0; 19 for (int i=1;i<cnm;i++) 20 if (!pd[i]) { 21 cout<<(i^l)<<‘ ‘; 22 l=i; 23 } 24 }
Codeforces Round #563 (Div. 2) D、Ehab and the Expected XOR Problem
标签:long ssis sub xor eof opera i++ title first
原文地址:https://www.cnblogs.com/beafreeman/p/11001328.html