Interesting Integers

아직 제출이 없습니다시간 제한20초메모리 제한1024 MB

문제

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 AA and BB. Find the number of interesting integers between AA and BB (both inclusive).

입력

The first line of the input gives the number of test cases, TTTT lines follow.

Each line represents a test case and contains two integers: AA and BB.

출력

For each test case, output one line containing Case #x: y, where xx is the test case number (starting from 1) and yy is the number of interesting integers between AA and BB (inclusive).

제한

  • 1T1001≤T≤100.

힌트

In Sample Case #1, since the product and the sum of digits are the same for single-digit integers, all integers between 11 and 99 are interesting.

In Sample Case #2, there are no interesting integers between 9191 and 9999.

In Sample Case #3, there are five interesting integers between 451451 and 460460:

  1. 451451 (product of its digits is 4×5×1=204×5×1=20, sum of its digits is 4+5+1=104+5+1=10).
  2. 453453 (product of its digits is 4×5×3=604×5×3=60, sum of its digits is 4+5+3=124+5+3=12).
  3. 456456 (product of its digits is 4×5×6=1204×5×6=120, sum of its digits is 4+5+6=154+5+6=15).
  4. 459459 (product of its digits is 4×5×9=1804×5×9=180, sum of its digits is 4+5+9=184+5+9=18).
  5. 460460 (product of its digits is 4×6×0=04×6×0=0, sum of its digits is 4+6+0=104+6+0=10).