|
||||||||||
Word GameTime Limit: 8000/4000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 149 Accepted Submission(s): 15 Problem Description If you have a circle consists of L characters. We can define one of them as 0th character, and then 1st, 2nd ¡¡ (L -1)th along the clockwise. A string beginning with the ith character can be get from this circle, let's call it p[i] (All of these string has a length of L). From 0 to L -1, if there exists exactly K positions i make p[i] as same as p[0], then we call it a magic word. Give you n strings and a K. Please use all of these strings to creat a new string p. Tell me how many ways exists to construct a string p and make it a magic word. Input The input contains several cases. Each case starts with two integer n and K. Then follows n lines, each line contain a string. 0 < n <= 8, 0 < K <= 200, each string contain between 1 and 20 characters. Input ends with a case n = 0 and K = 0. Output Each case print a line with an integer. Sample Input
Sample Output
Hint hints: Use these strings, you can construct six "AABAABAAB". Author CTW Source | ||||||||||
|