The Number of Palindromes

Time Limit: 3000ms
Memory Limit: 262144KB
This problem will be judged on HDU. Original ID: 3948
64-bit integer IO format: %I64d      Java class name: Main

Description

Now, you are given a string S. We want to know how many distinct substring of S which is palindrome.

Input

The first line of the input contains a single integer T(T<=20), which indicates number of test cases.
Each test case consists of a string S, whose length is less than 100000 and only contains lowercase letters.

Output

For every test case, you should output "Case #k:" first in a single line, where k indicates the case number and starts at 1. Then output the number of distinct substring of S which is palindrome.

Sample Input

3
aaaa
abab
abcd

Sample Output

Case #1: 4
Case #2: 4
Case #3: 4

Source

Language: 
Theme: 
Share Code? 

Powered by NB231 | Current Style: .