aab aba baa

AtCoder
IDabc202_d
Time2000ms
Memory256MB
Difficulty
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 `a` and $B$ occurrences of `b`. * All values in input are integers. ## Input Input is given from Standard Input in the following format: $A$ $B$ $K$ [samples]
Samples
Input #1
2 2 4
Output #1
baab

Here are the strings containing two `a`s and two `b`s in the lexicographical order: `aabb`, `abab`, `abba`, `baab`, `baba`, and `bbaa`. The fourth string, `baab`, should be printed.
Input #2
30 30 118264581564861424
Output #2
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

$K$ may not fit into a $32$\-bit integer type.
API Response (JSON)
{
  "problem": {
    "name": "aab aba baa",
    "description": {
      "content": "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.",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "abc202_d"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "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.\n\n## Constraints\n\n*   $1 \\leq A, B \\le...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments