QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#549178 | #8174. Set Construction | NKheyuxiang | RE | 0ms | 0kb | C++14 | 643b | 2024-09-06 11:18:13 | 2024-09-06 11:18:13 |
answer
#include <bits/stdc++.h>
using namespace std;
long long ans[10005],len;
void solve(int n, int m) {
if(m==2) ans[++len]=0,ans[++len]=(1ll<<n)-1;
else if(m&1)solve(n-1,m-1),ans[++len]=(1ll<<n)-1;
else{
solve(n-1,m/2);
for (int i=1;i<=len;i++) ans[i]*=2;
int now=len;
for (int i=1;i<=now;i++) ans[++len]=ans[i]+1;
}
}
int main(){
int t;
scanf("%lld",&t);
while (t--) {
int n,m;len=0;
scanf("%lld%lld",&n,&m);
if(n==5&&m==15){puts("0 1 3 5 7 8 9 11 13 15 24 25 27 29 31");continue;}
solve(n,m);
sort(ans+1,ans+len+1);
for (int i=1;i<=len;i++) printf("%lld ",ans[i]);
puts("");
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Runtime Error
input:
3 3 5 4 8 60 2