#P16872. [GKS 2022 #A] Interesting Integers
[GKS 2022 #A] Interesting Integers
Problem Description
Let us call an integer interesting if the product of its digits is divisible by the sum of its digits. You are given two integers and . Find the number of interesting integers between and (both inclusive).
Input Format
The first line of the input gives the number of test cases, . lines follow.
Each line represents a test case and contains two integers: and .
Output Format
For each test case, output one line containing Case : , where is the test case number (starting from ) and is the number of interesting integers between and (inclusive).
4
1 9
91 99
451 460
501 1000
Case #1: 9
Case #2: 0
Case #3: 5
Case #4: 176
Hint
In Sample Case #, since the product and the sum of digits are the same for single-digit integers, all integers between and are interesting.
In Sample Case #, there are no interesting integers between and .
In Sample Case #, there are interesting integers between and :
-
(product of its digits is , sum of its digits is ).
-
(product of its digits is , sum of its digits is ).
-
(product of its digits is , sum of its digits is ).
-
(product of its digits is , sum of its digits is ).
-
(product of its digits is , sum of its digits is ).
Limits
.
Test Set
.
Test Set
.