Neq Number

AtCoder
IDarc173_a
Time2000ms
Memory256MB
Difficulty
A positive integer $X$ is called a **"Neq Number"** if it satisfies the following condition: * When $X$ is written in decimal notation, no two adjacent characters are the same. For example, $1$, $173$, and $9090$ are Neq Numbers, while $22$ and $6335$ are not. You are given a positive integer $K$. Find the $K$\-th smallest Neq Number. You have $T$ test cases to solve. ## Constraints * $1 \leq T \leq 100$ * $1 \leq K \leq 10^{12}$ * All input values are integers. ## Input The input is given from Standard Input in the following format: $T$ $\mathrm{case}_1$ $\vdots$ $\mathrm{case}_T$ Each case is given in the following format: $K$ [samples]
Samples
Input #1
3
25
148
998244353
Output #1
27
173
2506230721

For the first test case, here are the smallest $25$ Neq Numbers in ascending order:

*   The nine integers from $1$ to $9$
*   The nine integers from $10$ to $19$, excluding $11$
*   The seven integers from $20$ to $27$, excluding $22$

Thus, the $25$\-th smallest Neq Number is $27$.
API Response (JSON)
{
  "problem": {
    "name": "Neq Number",
    "description": {
      "content": "A positive integer $X$ is called a **\"Neq Number\"** if it satisfies the following condition: *   When $X$ is written in decimal notation, no two adjacent characters are the same. For example, $1$, $",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "arc173_a"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "A positive integer $X$ is called a **\"Neq Number\"** if it satisfies the following condition:\n\n*   When $X$ is written in decimal notation, no two adjacent characters are the same.\n\nFor example, $1$, $...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments