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
80
81
82
83
84
85
86
87
88
89
90
91
#include<iostream>
using namespace std;

char wypisz(int j, char z, int czy_start)
{
	if (czy_start)
	{
	if (j == 0) 
		return 'a';
	if (j == 1)
		return 'b';
	if (j == 2)
		return 'c';
	}

	if (z == 'a')
		if (j == 0)
			return 'b';
		else 
			return 'c';
	if (z == 'b')
		if (j == 0)
			return 'a';
		else 
			return 'c';
	if (z == 'c')
		if (j == 0)
			return 'a';
		else 
			return 'b';

	return z;
}

unsigned long long potega(unsigned long long n)
{
	unsigned long long pot = 1;
	for (int i = 1;i <= n;i++)
		pot *= 2;
	return pot;
}

int main(){

	unsigned long long m,k,i,h,n;
	int j, czy_start, czy_bylo;
	char z;
	m = 0;
	z=' ';
	czy_start = 1;
	czy_bylo = 1;
	j = 0;

	cin>>n>>k;
	while (n>61)
	{
		z = wypisz(j,z,czy_start);
		czy_start = 0;
		czy_bylo = 0;
		cout<<z;
		m+=1;
		n--;
	}
	if (czy_bylo)
		if (k > 3 * potega(n) - 3)
		{
			cout<<"NIE"<<"\n";
			return 0;
		}

	while (m < k)
	{
		i = potega(n) - 1;
		j = 0;
		h = i;
		while (m + h < k)
		{
			j++;
			h+=i;
		}
		z = wypisz(j,z,czy_start);
		cout<<z;
		czy_start = 0;
		m += i * j + 1;
		n--;

	}
	cout<<"\n";
	return 0;
	
}