#P16518. [GKS 2015 #E] Lazy Spelling Bee
[GKS 2015 #E] Lazy Spelling Bee
题目描述
In the Lazy Spelling Bee, a contestant is given a target word to spell. The contestant's answer word is acceptable if it is the same length as the target word, and the -th letter of is either the -th, th, or th letter of , for all in the range of the length of . (The first letter of must match either the first or second letter of , since the 0th letter of doesn't exist. Similarly, the last letter of must match either the last or next-to-last letter of .) Note that the target word itself is always an acceptable answer word.
You are preparing a Lazy Spelling Bee, and you have been asked to determine, for each target word, how many distinct acceptable answer words there are. Since this number may be very large, please output it modulo ().
输入格式
The first line of the input gives the number of test cases, . test cases follow; each consists of one line with a string consisting only of lowercase English letters (a through z).
输出格式
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 distinct acceptable answer words, modulo .
4
ag
aa
abcde
x
Case #1: 4
Case #2: 1
Case #3: 108
Case #4: 1
提示
In sample case #1, the acceptable answer words are aa, ag, ga, and gg.
In sample case #2, the only acceptable answer word is aa.
Limits
.
Small dataset (Test Set 1 - Visible)
length of each string .
Large dataset (Test Set 2 - Hidden)
length of each string .