#3490

Count Beautiful Numbers

hard · 23.2% accepted · 51 likes · top 3%

dynamic programming

Description

You are given two positive integers, l and r. A positive integer is called beautiful if the product of its digits is divisible by the sum of its digits.

Return the count of beautiful numbers between l and r, inclusive.

Solution