QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#549179#8174. Set ConstructionNKheyuxiangRE 0ms0kbC++14654b2024-09-06 11:18:512024-09-06 11:18:51

Judging History

你现在查看的是最新测评结果

  • [2024-09-06 11:18:51]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2024-09-06 11:18:51]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
long long ans[10005],len;
void solve(long long n,long long 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;
}

详细

Test #1:

score: 0
Runtime Error

input:

3
3 5
4 8
60 2

output:


result: