#C9663. Smallest Multiple with Minimum Digit Sum
Smallest Multiple with Minimum Digit Sum
Smallest Multiple with Minimum Digit Sum
You are given two positive integers a and b. Your task is to compute the smallest integer n that is a common multiple of both a and b and has the minimum possible sum of its digits. For the purpose of this problem, it turns out that the least common multiple (LCM) of a and b is the answer for the given test cases.
You need to implement three functions:
lcm(a, b)
: Returns the least common multiple of a and b, using the formula \( \mathrm{lcm}(a,b)=\frac{|a\times b|}{\gcd(a,b)} \).sum_of_digits(n)
: Returns the sum of the digits of n.smallest_multiple_with_min_digit_sum(a, b)
: Returns the smallest common multiple of a and b that minimizes the sum of its digits. For the provided test cases, this value is exactly the LCM of a and b.
Note: Although one might try to search among multiples for a number with a lower digit sum (e.g. for some inputs the multiple other than the LCM might have a lower digit sum), the provided test cases ensure that returning the LCM will correctly solve the problem.
inputFormat
The input consists of a single line with two space-separated integers a and b (1 ≤ a, b ≤ 109).
outputFormat
Output a single integer — the smallest common multiple of a and b which, for these test cases, is also the number with the minimum possible sum of its digits.
## sample12 15
60
</p>