STRANG - English
Someone thinks that someone thinks that someone thinks that...
Trang is a nice girl who is keen on learning English to make her study abroad dream come true. She practices everyday that her progress impresses the teacher. On Trang 's birthday, she receive an English book from her teacher. The interesting thing is that the book contain only one (very long) sentence! Trang is surprised that she cannot understand any word and decides to learn every word in the sentence. She wants to learn the longest word first, but it should appear in the string a few times since Trang is curious about the meaning of the sentence. Help her to find the first word to learn!
You are given a string S (the sentence), where its length can be up to 100000, including only lowercase alphabetical letters ('a' ... 'z'). A word is defined as a subtring of consecutive characters and each is assigned an “important” value, which is equal ((length of the word) * (number of times it occurred in the sentence)).
Input
One line containing the string S.
Output
One number, the “important” value of the most “important” word.
Sample
Input: abcabcdddlo Output: 11
Input: aaaaaa Output: 12
hide comments
:D:
2015-01-05 22:56:00
For the second output: you have 6 distinct substrings: "a", "aa", ..., "aaaaaa". Importance values are as follows: 1*6, 2*5, 3*4, 4*3, 5*2, 6*1 (note that occurrences can overlap). So the biggest one here is 12. |
|
Akash:
2014-12-27 06:45:41
More explanation is needed. |
|
Malinga:
2014-12-25 12:13:29
How is the output 12 for 2nd input ?? |
Added by: | Le Anh Duc - A2K42 PBC |
Date: | 2014-12-04 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 |