#P16874. [GKS 2022 #B] Palindromic Factors

[GKS 2022 #B] Palindromic Factors

Problem Description

You are given a positive integer AA. Find the number of factors of AA which are palindromes. A number is called a palindrome if it remains the same when the digits in decimal representation are reversed. For instance, 121121 is a palindrome, while 123123 is not.

Input Format

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

Each line represents a test case and contains a single integer AA.

Output Format

For each test case, output one line containing Case #xx: yy, where xx is the test case number (starting from 11) and yy is the number of factors of AA which are palindromes.

4
6
10
144
242
Case #1: 4
Case #2: 3
Case #3: 7
Case #4: 6

Hint

In the first test case, AA has 44 factors which are palindromes: 11, 22, 33, and 66.

In the second test case, AA has 33 factors which are palindromes: 11, 22, and 55.

In the third test case, AA has 77 factors which are palindromes: 11, 22, 33, 44, 66, 88, and 99.

In the fourth test case, AA has 66 factors which are palindromes: 11, 22, 1111, 2222, 121121, and 242242.

Limits

1T1001 \le T \le 100.

Test Set 11

1A1031 \le A \le 10^3.

Test Set 22

1A10101 \le A \le 10^{10}.