Problem C
Palindromic Naming
Yraglac is expecting to have a child in the near future.
Being a mathematically-minded person, he would like his child’s
name to be a palindrome – that is, reads the same when read
forward and backward. Given a name, he would like to count the
number of ways he can create a palindromic name by removing
zero or more letters. For example, given the name “abcdb”, he
can remove the letters “a” and “c” to get the palindrome “bdb”.
Of course, the resulting name must not be empty. The answer
might be very large so you should output the answer modulo
Input
The first line contains a single integer
Output
For each test case, output a single line containing the
answer modulo
Sample Input 1 | Sample Output 1 |
---|---|
5 bob a aa aaa abcdb |
5 1 3 7 8 |