#P1900. 自我数
自我数
Description
In 1949, Indian mathematician D. R. Daprekar discovered a class of numbers called Self-Numbers. For every positive integer , we define as plus the sum of its digits. For example, . Given any positive integer as a starting point, we can construct an infinite increasing sequence: For example, if you start from , the next number is , the next is , and the one after that is , so the sequence you generate looks like this: $33, 39, 51, 57, 69, 84, 96, 111, 114, 120, 123, 129, 141, \ldots$ The number is called a generator of . In the sequence above, is a generator of , is a generator of , is a generator of , and so on. Some numbers have more than one generator, such as , whose generators can be and . A number with no generator is called a Self-Number. The first Self-Numbers are . We denote the -th Self-Number by , so .
Input Format
The input contains integers , where and , separated by spaces and newlines.
Output Format
On the first line, output a single number: the count of Self-Numbers in the closed interval . The second line must contain numbers separated by spaces, namely . It is guaranteed that all of are less than . (For example, if , can be from to , but not , because .)
100 10
1 2 3 4 5 6 7 11 12 13
13
1 3 5 7 9 20 31 75 86 97
Hint
For of the testdata, and .
Translated by ChatGPT 5
京公网安备 11011102002149号