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
/* Konrad Staniszewski */


#include <bits/stdc++.h>


using namespace std;


typedef unsigned long long ull;
const int MAX_N = 1000000;

ull dynTab[MAX_N + 7];
ull dynTab_prefSum[MAX_N + 7];
int dl = 0;
ull n, k;

char opcje[3][3] = {"bc", "ac", "ab"};
int main()
{
	scanf("%llu%llu", &n, &k);
	dynTab[1] = 1;
	dynTab_prefSum[1] = 1;
	for (unsigned i = 2; i <= n; ++i)
	{
		dynTab[i] += 2ULL*dynTab[i - 1];
		dynTab_prefSum[i] = dynTab[i] + dynTab_prefSum[i - 1];
		//printf("a%u %llu\n", i, dynTab_prefSum[i]);
		//printf("b%u %llu\n", i, dynTab[i]);
		if (dynTab_prefSum[i] >= 3689348814741910323ULL)
		{
			dynTab_prefSum[i] = 3689348814741910323ULL;
		}
		
	}
	if (dl == 0)
		dl = n;
		
	if (3ULL*dynTab_prefSum[dl] < k)
	{
		puts("NIE");
		return 0;
	}
		
	ull sum = 0;
	unsigned bef = 0;
	for (int j = 0; j <= 2; ++j)
	{
		//printf("e%u %llu\n", dl, dynTab_prefSum[dl]);
		//printf("e%u %llu\n", dl, dynTab[dl]);
		if (dynTab_prefSum[dl]*(j + 1) + sum  >= k)
		{
			putchar('a' + j);
			sum += dynTab_prefSum[dl]*(j) + 1;
			bef = j;
			break;
		}
	}
	
	for (unsigned i = dl - 1; i >= 1; --i)
	{
	    //printf("\n------\ne%u %llu %llu\n", i, dynTab_prefSum[i], sum);
		//printf("e%u %llu %llu\n-----\n", i, dynTab[i], sum);
		for (int j = 0; j <= 1; ++j)
		{
			if (sum >= k)
				return 0;
			
			if (dynTab_prefSum[i]*(j + 1) + sum >= k)
			{
				putchar(opcje[bef][j]);
				sum += dynTab_prefSum[i]*(j) + 1;
				bef = opcje[bef][j] - 'a';
				break;
			}
		}
	}
	
}