#P8982. 「DROI」Round 1 下坠
「DROI」Round 1 下坠
Background
Does falling have an end?
Problem Description
is a function defined on .
Let be the -th digit of from low to high. Then , where is the number of digits of .
For a number , if there exists such that , then we call a falling number.
Now there are queries. Each query gives a positive integer .
Let be the -th smallest falling number among all falling numbers. Please find the smallest such that . If there is no that satisfies the condition, output .
Input Format
The first line contains an integer , the number of queries.
The next line contains numbers. The -th number is the for the -th query.
Output Format
Output one line with numbers. The -th number is the answer you found for the -th query.
3
1 2 3
1 2 3
3
9 14 46666666
9 18 -1
Hint
Sample Explanation #1
Note that the domain of is , so is not a falling number. Therefore, the first three falling numbers are , and the corresponding values are .
Sample Explanation #2
The -th and -th falling numbers are and , and their corresponding values are and . It can be proven that the -th falling number corresponds to .
Constraints
For of the testdata: , .
For of the testdata: .
For of the testdata: .
For another of the testdata: for every queried falling number , we have or .
Please note the unusual time limit.
Translated by ChatGPT 5