F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Spy

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 932    Accepted Submission(s): 436


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
abc aab abcadabcabcad aaabbbaaaabbbaa abcababcd
 

Sample Output
Case 1: 3 Case 2: 2 Case 3: 5 Case 4: 6 Case 5: 4
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-04-20 01:31:48, Gzip enabled