Imagine you're a mathematician fascinated by the hidden beauty in numbers! You've discovered that some numbers have a special property where the product of their digits is divisible by the sum of their digits.
Given two positive integers l and r, your task is to count how many beautiful numbers exist in the range [l, r] inclusive.
What makes a number beautiful?
A positive integer is called beautiful if (product of digits) % (sum of digits) == 0
Example: The number 144 is beautiful because:
• Product of digits: 1 × 4 × 4 = 16
• Sum of digits: 1 + 4 + 4 = 9
• Since 16 % 9 ≠ 0, actually 144 is NOT beautiful
Let's try 132:
• Product: 1 × 3 × 2 = 6
• Sum: 1 + 3 + 2 = 6
• Since 6 % 6 = 0, 132 IS beautiful! ✨
Input & Output
Constraints
- 1 ≤ l ≤ r ≤ 109
- The range [l, r] can contain up to 109 numbers
- Important: Numbers containing digit 0 have product = 0, which is divisible by any positive sum