#define NDEBUG
#include<bits/stdc++.h>
using namespace std;
#define REP(I,N) for(int I=0;I<(N);I++)
typedef long long ll;
const long long INFTY=(long long)(2147483647)*(long long)(2147483647)*(long long)2;
char b[1000001]={'\0'};
int p=0;
int n;
ll k, r;
ll pow_pom[64];
bool start=true;
inline void put(char x){
b[p++]=x;
}
inline void putno(){
put('N');put('I');put('E');
}
inline ll pow(int m){
return m>=60?INFTY:pow_pom[m];
}
inline char get1(){
return b[p-1]=='a'?'b':'a';
}
inline char get2(){
return b[p-1]=='c'?'b':'c';
}
inline void iter(bool s){
ll m=pow(n-p);
if(s){
if(m>=r){
put('a');
} else if(m+m>=r){
put('b');
r-=m;
} else {
put('c');
r-=m+m;
}
r--;
}else{
if(m>=r){
put(get1());
} else {
put(get2());
r-=m;
}
r--;
}
}
int main(){
ios::sync_with_stdio(false);
cin>>n>>k;
r=k;
REP(i,61) pow_pom[i]=((1LL)<<i)-1;
if(pow(n)*3<k){
putno();
}else{
while(r>0){
iter(start);
start=false;
}
}
printf("%s\n",b);
return 0;
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | #define NDEBUG #include<bits/stdc++.h> using namespace std; #define REP(I,N) for(int I=0;I<(N);I++) typedef long long ll; const long long INFTY=(long long)(2147483647)*(long long)(2147483647)*(long long)2; char b[1000001]={'\0'}; int p=0; int n; ll k, r; ll pow_pom[64]; bool start=true; inline void put(char x){ b[p++]=x; } inline void putno(){ put('N');put('I');put('E'); } inline ll pow(int m){ return m>=60?INFTY:pow_pom[m]; } inline char get1(){ return b[p-1]=='a'?'b':'a'; } inline char get2(){ return b[p-1]=='c'?'b':'c'; } inline void iter(bool s){ ll m=pow(n-p); if(s){ if(m>=r){ put('a'); } else if(m+m>=r){ put('b'); r-=m; } else { put('c'); r-=m+m; } r--; }else{ if(m>=r){ put(get1()); } else { put(get2()); r-=m; } r--; } } int main(){ ios::sync_with_stdio(false); cin>>n>>k; r=k; REP(i,61) pow_pom[i]=((1LL)<<i)-1; if(pow(n)*3<k){ putno(); }else{ while(r>0){ iter(start); start=false; } } printf("%s\n",b); return 0; } |
English