#Lutece0373. Concat Number
Concat Number
Migrated from Lutece 373 Concat Number
All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.
Description
Totalfrank is fond of numbers. One day, he found a kind of interesting numbers called Concat Number which is a concatenation of two numbers and divided exactly by the product of them. For example in decimal, 1352
() is a concatenation of 13
() and 52
(), and 1352
is divided exactly by ; in octal, 53254
() is a concatenation of 53
() and 254
(), and 53254
() = 22188
() is divided exactly by 53
() 254
() 7396
(). Note that the two numbers split from Concat Number are positive without leading zeros.
Now he wants to know the number of Concat Numbers in range ( and are decimal numbers) in base .
Input
The first line of the input is an integer (), which stands for the number of test cases you need to solve.
Each case consists of three integers , , () on a single line.
Output
For every test case, you should output Case #k:
first, where indicates the case number and starts at . Then output the answer.
Samples
2
10 1 100
8 1 100
Case #1: 5
Case #2: 7
Resources
The 9th UESTC Programming Contest Final