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
#include <stdio.h>

int main(void)
{
    int n;
    long long k;
    char c = '\0';

    scanf("%d%lld", &n, &k);

    if (n <= 60) {
        long long m, o;

        k--;
        m = (1LL << n) - 1;
        o = k / m;

        if (o > 2) {
            printf("NIE\n");
            return 0;
        }

        c = "abc"[o];
        k %= m;
        n--;
        fputc(c, stdout);
    }

    while (k > 0) {
        if (n > 60 || k < (1LL << n)) {
            c = (c == 'a') ? 'b' : 'a';
            k--;
            fputc(c, stdout);
        }

        else {
            c = (c == 'c') ? 'b' : 'c';
            k -= (1LL << n);
            fputc(c, stdout);
        }

        n--;
    }

    fputc('\n', stdout);
    return 0;
}