Little C has just finished learning about string matching, and he is practicing now.
For a string
More specifically, we can define
We also recursively define
Little C's problem is asking to find the number of ways of
Little C doesn't know how to solve this problem, so he asked you for help.
Input Specification
A positive integer
The next
Output Specification
For each data set, output a line with one integer indicating the answer.
Sample Input 1
3
nnrnnr
zzzaab
mmlmmlo
Sample Output 1
8
9
16
Explanation for Sample 1
All possible ways are
, , . , , . , , . , , . , , . , , . , , . , , .
Sample Input 2
5
kkkkkkkkkkkkkkkkkkkk
lllllllllllllrrlllrr
cccccccccccccxcxxxcc
ccccccccccccccaababa
ggggggggggggggbaabab
Sample Output 2
156
138
138
147
194
Additional Samples
Additional samples can be found here.
- Sample 3 (
string3.in
andstring3.ans
). - Sample 4 (
string4.in
andstring4.ans
).
Constraints
Test Case | Additional Constraints | |
---|---|---|
None | ||
None | ||
None | ||
None | ||
None |
For all test cases,
Problem translated to English by .
Comments