#C10482. Lexicographically Smallest Special Palindrome
Lexicographically Smallest Special Palindrome
Lexicographically Smallest Special Palindrome
You are given an integer k. Your task is to form a palindrome of exactly k characters according to the following rules:
- If k = 1, the answer is
a
. - If k is even, the answer is a string consisting of k copies of the character
a
. - If k is odd and greater than 1, let \( h = \lfloor k/2 \rfloor \). The answer is formed by concatenating \( a^h \), then the character
b
, and then \( a^h \) again. In other words, the answer isah b ah
.
This ensures that for odd lengths (except when k = 1), the palindrome has exactly one b
placed in the middle, while even lengths consist solely of a
's.
inputFormat
The input is read from standard input and consists of multiple test cases. The first line contains an integer T representing the number of test cases. Each of the following T lines contains a single integer k, which is the required length of the palindrome.
Formally, the input format is:
T k1 k2 ... kT
outputFormat
For each test case, output the required palindrome on a separate line.
For example, if the input is:
3 1 2 3
Then the output should be:
a aa aba## sample
3
1
2
3
a
aa
aba
</p>