95pts
查看原帖
95pts
91737
rex_qwq楼主2023/10/20 15:28

不知道是不是溢出但是我开了128

#include<bits/stdc++.h>
using namespace std;
#define int __int128
int n,k;
string s;
inline void dfs(int dep,int k){
	if(dep==1){
		if(k&1)
			s=s+'0';
		else
			s=s+'1';
		return;
	}
	if(k>(1LL<<(dep-1)))
		{s=s+'1';dfs(dep-1,(1LL<<dep)-k+1LL);}
	else
		{s=s+'0';dfs(dep-1,k);}
	return;
}
inline void read(int &x){
	char ch=getchar();
	while(ch<48||ch>57)
		ch=getchar();
	while(ch>=48&&57>=ch)
		x=(x<<1LL)+(x<<3LL)+(int)(ch-48LL),ch=getchar();
}
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(),cout.tie();
	read(n),read(k);
	k++;
	s="";
	dfs(n,k);
	cout<<s<<'\n';
	return 0;
}
2023/10/20 15:28
加载中...