Олимпиадный тренинг

Задача 42972. tasty number


Задача

Темы: Цикл while
Gromozeka considers a natural number delicious if all its digits are distinct and the sum of its digits is equal to the number written on the cookie that Gromozeka eats.
Now Gromozeka is eating a cookie with the number n written on it. Help him find the smallest tasty number for such a cookie.
For example, if n = 10, then the smallest tasty number is 19 (1+9=10, all digits of 19 are different).

Input
The program takes as input an integer n (1 <= n <= 45).

Imprint
Print the answer to the problem.
 
 
Examples
# Input Output
1 10 19
2 1 1

Запрещенные операторы:str;::-1;reverse