#C3217. Smallest N for Uniform Digit Multiplication
Smallest N for Uniform Digit Multiplication
Smallest N for Uniform Digit Multiplication
You are given two integers L and R. Your task is to find the smallest non-negative integer N such that for every integer X in the inclusive range [L, R], the last digit of the product N \times X is the same.
In other words, there exists a digit \(d\) (0 ≤ d ≤ 9) for which the following holds:
[ \text{last digit}(N \times X) = d \quad \text{for all } X \text{ with } L \le X \le R. ]
Note: The trivial solution N = 0 always works since \(0 \times X = 0\) for any X, making the last digit (which is 0) the same for all terms in the range.
Input/Output Format: The input consists of two space-separated integers. The output is a single integer representing the smallest N satisfying the condition.
inputFormat
The input contains two integers L and R (separated by spaces or newline), where L and R define the range \([L, R]\).
outputFormat
Output a single integer: the smallest non-negative integer N such that for every integer X in the range \([L, R]\), the last digit of N \times X is identical.
## sample3 8
0