|
||||||||||
SpyTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 954 Accepted Submission(s): 448 Problem Description ¡°Be subtle! Be subtle! And use your spies for every kind of business. ¡± ¡ª Sun Tzu ¡°A spy with insufficient ability really sucks¡± ¡ª An anonymous general who lost the war You, a general, following Sun Tzu¡¯s instruction, make heavy use of spies and agents to gain information secretly in order to win the war (and return home to get married, what a flag you set up). However, the so-called ¡°secret message¡± brought back by your spy, is in fact encrypted, forcing yourself into making deep study of message encryption employed by your enemy. Finally you found how your enemy encrypts message. The original message, namely s, consists of lowercase Latin alphabets. Then the following steps would be taken: * Step 1: Let r = s * Step 2: Remove r¡¯s suffix (may be empty) whose length is less than length of s and append s to r. More precisely, firstly donate r[1...n], s[1...m], then an integer i is chosen, satisfying i ¡Ü n, n - i < m, and we make our new r = r[1...i] + s[1...m]. This step might be taken for several times or not be taken at all. What your spy brought back is the encrypted message r, you should solve for the minimal possible length of s (which is enough for your tactical actions). Input There are several test cases. For each test case there is a single line containing only one string r (The length of r does not exceed 105). You may assume that the input contains no more than 2 ¡Á 106 characters. Input is terminated by EOF. Output For each test case, output one line ¡°Case X: Y¡± where X is the test case number (starting from 1) and Y is the desired answer. Sample Input
Sample Output
Source | ||||||||||
|