#AT1796. D - aab aba baa
D - aab aba baa
D - aab aba baa
Score : $400$ points
Problem Statement
Among the strings of length $A + B$ containing $A$ occurrences of a and $B$ occurrences of b, find the string that comes $K$-th in the lexicographical order.
Constraints
- $1 \leq A, B \leq 30$
- $1 \leq K \leq S$, where $S$ is the number of strings of length $A + B$ containing $A$ occurrences of
aand $B$ occurrences ofb. - All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the answer.
2 2 4
baab
Here are the strings containing two as and two bs in the lexicographical order: aabb, abab, abba, baab, baba, and bbaa.
The fourth string, baab, should be printed.
30 30 118264581564861424
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
$K$ may not fit into a $32$-bit integer type.
相关
在下列比赛中: