Palindromic Factors
Time limit2sMemory limit1024 MB
Count the divisors of A that read the same forward and backward in decimal.
- Level
Easy3 of 10
- Topics
- Math, Number theory
- Solved
- No attempts yet
Problem
You are given a positive integer . Find the number of factors of that are palindromes. A number is called a palindrome if it reads the same when the digits in its decimal representation are reversed. For instance, 121 is a palindrome, while 123 is not.
Input
The first line of the input gives the number of test cases, . lines follow. Each line contains a single integer .
Output
For each test case, output one line containing Case #x: y, where is the test case number (starting from 1) and is the number of factors of that are palindromes.
Constraints
.
Hint
In the first test case, has 4 palindromic factors: 1, 2, 3, and 6.
In the second test case, has 3 palindromic factors: 1, 2, and 5.
In the third test case, has 7 palindromic factors: 1, 2, 3, 4, 6, 8, and 9.
In the fourth test case, has 6 palindromic factors: 1, 2, 11, 22, 121, and 242.