308069: CF1462C. Unique Number

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Unique Number

题意翻译

给定正整数 $x$. 构造一个正整数满足: - 这个正整数的各位之和等于 $x$. - 这个正整数的每一位数字都不一样. - 在满足前两个条件的情况下,这个正整数是最小的那个. $T$ 组询问,对于每组询问,有解输出符合要求的正整数,无解输出 $-1$. 保证: $1\leq T\leq 50,1\leq x\leq 50.$

题目描述

You are given a positive number $ x $ . Find the smallest positive integer number that has the sum of digits equal to $ x $ and all digits are distinct (unique).

输入输出格式

输入格式


The first line contains a single positive integer $ t $ ( $ 1 \le t \le 50 $ ) — the number of test cases in the test. Then $ t $ test cases follow. Each test case consists of a single integer number $ x $ ( $ 1 \le x \le 50 $ ).

输出格式


Output $ t $ answers to the test cases: - if a positive integer number with the sum of digits equal to $ x $ and all digits are different exists, print the smallest such number; - otherwise print -1.

输入输出样例

输入样例 #1

4
1
5
15
50

输出样例 #1

1
5
69
-1

Input

题意翻译

给定正整数 $x$. 构造一个正整数满足: - 这个正整数的各位之和等于 $x$. - 这个正整数的每一位数字都不一样. - 在满足前两个条件的情况下,这个正整数是最小的那个. $T$ 组询问,对于每组询问,有解输出符合要求的正整数,无解输出 $-1$. 保证: $1\leq T\leq 50,1\leq x\leq 50.$

加入题单

算法标签: