import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.InputStream; import java.io.OutputStream; import java.util.ArrayList; import java.util.List; public class slo { public static char[] L = {'a', 'b', 'c'}; public static void main(String[] args) { long n = R.l(); long k = R.l(); long x = (long) Math.pow(2, n > 60 ? 60 : n) - 1; int p = 3; if (k > 3 * x) { System.out.println("NIE"); } else { while (k > 0) { k--; p = (int) (k / x) >= p ? (int) (k / x + 1) : (int) (k / x); W.c(L[p]); k = k % x; n--; x = (long) Math.pow(2, n > 60 ? 60 : n) - 1; } } W.flush(); } public static void go(long n, long k) { } static class R { static InputStream is=new BufferedInputStream(System.in); static int b='\n'; static void next(){try{b=is.read();}catch(Exception e){}} static void skip(){while(b=='\n'||b==' '||b=='\r'||b=='\t')next();} static char c(){skip();char c=(char)b;next();return c;} static int i(){skip();int i=0;while(b>='0'&&b<='9'){i=10*i+(b-'0');next();}return i;} static long l(){skip();long i=0;while(b>='0'&&b<='9'){i=10*i+(b-'0');next();}return i;} } static class W { static OutputStream os=new BufferedOutputStream(System.out,4096); static void b(int b){try{os.write(b);}catch(Exception e){}} static void c(char c){b(c);} static void cs(char c){c(c);space();} static void cn(char c){c(c);newLine();} static void i(int i){if(i>9)i(i/10);b('0'+(i%10));} static void is(int i){i(i);space();} static void in(int i){i(i);newLine();} static void l(long l){if(l>9)l(l/10);b('0'+(int)(l%10));} static void ls(int l){l(l);space();} static void ln(int l){l(l);newLine();} static void s(String s){try{os.write(s.getBytes());}catch(Exception e){}} static void ss(String s){s(s);space();} static void sn(String s){s(s);newLine();} static void tn(boolean b){sn(b?"TAK":"NIE");} static void space(){b(' ');} static void newLine(){b('\n');} static void flush(){try{os.flush();}catch(Exception e){}}; } }
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 | import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.InputStream; import java.io.OutputStream; import java.util.ArrayList; import java.util.List; public class slo { public static char[] L = {'a', 'b', 'c'}; public static void main(String[] args) { long n = R.l(); long k = R.l(); long x = (long) Math.pow(2, n > 60 ? 60 : n) - 1; int p = 3; if (k > 3 * x) { System.out.println("NIE"); } else { while (k > 0) { k--; p = (int) (k / x) >= p ? (int) (k / x + 1) : (int) (k / x); W.c(L[p]); k = k % x; n--; x = (long) Math.pow(2, n > 60 ? 60 : n) - 1; } } W.flush(); } public static void go(long n, long k) { } static class R { static InputStream is=new BufferedInputStream(System.in); static int b='\n'; static void next(){try{b=is.read();}catch(Exception e){}} static void skip(){while(b=='\n'||b==' '||b=='\r'||b=='\t')next();} static char c(){skip();char c=(char)b;next();return c;} static int i(){skip();int i=0;while(b>='0'&&b<='9'){i=10*i+(b-'0');next();}return i;} static long l(){skip();long i=0;while(b>='0'&&b<='9'){i=10*i+(b-'0');next();}return i;} } static class W { static OutputStream os=new BufferedOutputStream(System.out,4096); static void b(int b){try{os.write(b);}catch(Exception e){}} static void c(char c){b(c);} static void cs(char c){c(c);space();} static void cn(char c){c(c);newLine();} static void i(int i){if(i>9)i(i/10);b('0'+(i%10));} static void is(int i){i(i);space();} static void in(int i){i(i);newLine();} static void l(long l){if(l>9)l(l/10);b('0'+(int)(l%10));} static void ls(int l){l(l);space();} static void ln(int l){l(l);newLine();} static void s(String s){try{os.write(s.getBytes());}catch(Exception e){}} static void ss(String s){s(s);space();} static void sn(String s){s(s);newLine();} static void tn(boolean b){sn(b?"TAK":"NIE");} static void space(){b(' ');} static void newLine(){b('\n');} static void flush(){try{os.flush();}catch(Exception e){}}; } } |