#K91587. Self-Dividing Numbers
Self-Dividing Numbers
Self-Dividing Numbers
Given two integers L and R, find all the self-dividing numbers in the range [L, R]. A self-dividing number is defined as a number that is divisible by every digit it contains. Formally, a number \( n \) is self-dividing if for every digit \( d \) in its decimal representation, the following conditions hold:
\( d \neq 0 \) and \( n \mod d = 0 \).
For example, 128 is self-dividing since \( 128 \mod 1 = 0 \), \( 128 \mod 2 = 0 \), and \( 128 \mod 8 = 0 \).
inputFormat
A single line containing two space-separated integers L and R representing the range.
outputFormat
Print the self-dividing numbers between L and R in increasing order, separated by a space. If there are no such numbers, output an empty line.## sample
1 22
1 2 3 4 5 6 7 8 9 11 12 15 22