AtCoder Regular Contest 173
A
Neq Number
AtCoder
⌀ 1073
原题
←B →
翻译中…

Problem Statement

翻译中…

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

翻译中…

Output

翻译中…

Print $T$ lines. The $i$-th line should contain the answer for the $i$-th test case.

翻译中…

样例

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$.
题目信息
题号
arc173_a
时间限制
2 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。