#K93262. Smallest Balanced String
Smallest Balanced String
Smallest Balanced String
You are given an integer L
and your task is to generate the smallest possible balanced string that satisfies the following conditions:
- The string must contain at least one 'a' and one 'b'.
- The length of the string is greater than or equal to
L
. - The string is constructed by alternating the characters 'a' and 'b', starting with 'a'.
The balanced string is defined such that for an even L
the output is exactly "ab"
repeated L/2
times, and for an odd L
the output is "ab"
repeated floor(L/2)
times with an additional 'a' appended at the end.
For example:
- If
L = 2
, the output should be"ab"
. - If
L = 5
, the output should be"ababa"
. - If
L = 8
, the output should be"abababab"
.
In mathematical terms, let the answer string be S. Then, for an even L
,
\[
S = (ab)^{\frac{L}{2}}
\]
and for an odd L
,
\[
S = (ab)^{\left\lfloor\frac{L}{2}\right\rfloor}a
\]
inputFormat
The input consists of a single integer L
read from standard input.
outputFormat
Output the smallest balanced string satisfying the conditions mentioned above to standard output.
## sample2
ab