#P9843. String Magic (Easy Version)
String Magic (Easy Version)
String Magic (Easy Version)
Problem Description
Z is learning string theory and he finds a difficult problem. Given a string of length (indexed from to ) , define equal to the number of pair that:
- ( is even)
- is a palindrome Here denotes the substring of with index from to . A palindrome is a string that reads the same from left to right as from right to left. To solve this problem, Z needs to calculate . He doesn't know how to solve it, but he knows it's easy for you. Please help him.
Input
The first line contains one integer which represents the number of test cases. For each test case: One line contains a string . It's guaranteed that the string only contains lowercase letters.
Output
For each test case: Print one line containing one integer which represents .
Sample Input
3
aaaa
abaaba
ababa
Sample Output
4
2
0
Source
2023“钉耙编程”中国大学生算法设计超级联赛(5)