CF 1714B - Remove Prefix
Find the minimum number with the given sum of digits s such that all digits in it are distinct (i.e. all digits are unique).
For example, if s=20, then the answer is 389. This is the minimum number in which all digits are different and the sum of the digits is 20 (3+8+9=20).
For the given s print the required number.
Input
The first line contains an integer t (1≤t≤45) — the number of test cases.
Each test case is specified by a line that contains the only integer s
?(1≤s≤45).
Output
Print t integers — the answers to the given test cases.
------------------------------------------------------------------
找到具有給定數(shù)字總和 s 的最小數(shù)字,使得其中的所有數(shù)字都不同(即所有數(shù)字都是唯一的)。
例如,如果s=20,則答案為389。這是所有數(shù)字都不同且數(shù)字之和為20(3+8+9=20)的最小數(shù)字。
對于給定的 s,打印所需的數(shù)字。
輸入
第一行包含一個整數(shù) t (1≤t≤45) — 測試用例的數(shù)量。
每個測試用例由包含唯一整數(shù) s 的行指定
? (1≤s≤45)。
輸出
打印 t 個整數(shù) — 給定測試用例的答案。
-------------------
配合數(shù)組進行處理要方便些,下面是代碼: