3473. Mr. Panda and Geometric Sequence

单测试点时限: 3.0 秒

内存限制: 512 MB

Mr. Panda likes playing with numbers. One day he picked up a number 3612 and found it’s interesting. 3612 can be divided into 3 numbers 3, 6 and 12 which forms an integer geometric sequence.

An integer geometirc sequence is a sequence of at least 3 positive integer numbers , also there is a positive number () that for each (), .

Mr. Panda named this kind of numbers “Happy Number”. He also announced that leading zeros are forbidden, which means there should be no extra zeros before the numbers. Now Mr. Panda would like to know how many Happy Numbers are between and inclusive.

输入

The first line of the input gives the number of test cases (). cases follow. Each test case contains one line which consists of two numbers and ().

输出

For each test case, output one line containing Case #x: y, where x is the test case number (starting from 1) and y is the number of Happy Numbers between and inclusive.

样例

Input
4
123 124
468 470
248 248
124816 124832
Output
Case #1: 1
Case #2: 1
Case #3: 1
Case #4: 1

2 人解决,4 已尝试。

3 份提交通过,共有 9 份提交。

9.9 EMB 奖励。

创建: 11 月,4 周前.

修改: 11 月,4 周前.

最后提交: 8 月,3 周前.

来源: ECL-Final 2017

标签