#C10370. Jumping Numbers
Jumping Numbers
Jumping Numbers
In this problem, you are given an integer (N). A number is called a jumping number if the absolute difference between every pair of adjacent digits is exactly 1. More formally, a non-negative integer (x) is a jumping number if for its decimal representation (d_0d_1\ldots d_k) (where (d_0) is the most significant digit), it holds that for every (i=1,2,\ldots,k), $$|d_i-d_{i-1}|=1.$$ Note that all single digit numbers are trivially jumping numbers.
Your task is to print all the jumping numbers less than or equal to (N) in increasing order. In the case when (N < 0), you should output nothing (i.e. an empty output line).
Example: If (N = 50), the jumping numbers are: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 21, 23, 32, 34, 43, 45.
inputFormat
The first line contains a single integer (T) denoting the number of test cases. Each of the following (T) lines contains a single integer (N), for which you need to find all the jumping numbers less than or equal to (N).
outputFormat
For each test case, output a single line containing the jumping numbers in increasing order, separated by a single space. If (N < 0) or there are no jumping numbers, output an empty line.## sample
2
10
50
0 1 2 3 4 5 6 7 8 9 10
0 1 2 3 4 5 6 7 8 9 10 12 21 23 32 34 43 45
</p>