HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Volumes > Problems from everywhere > problem:


TopCoder-6. 50759 - Text Statistics

Guest
• Discussion of problem (1)

Volume problems

• KBH-1013. 50618 - Code Correction
• VologdaInterUni-D. 50610 - Feasibility
• 50561 - Lucky tickets
• 50590 - Bronze medalists
• 50604 - Viruses
• 50611 - Maximum of the minima
• 50642 - Draft board
• 50665 - Intersecting rectangles
• TopCoder-6. 50759 - Text Statis...
• TopCoder-7. 50244 - Chessboard P...
• VologdaInterCity-A. 50614 - Numbe...
• VologdaInterCity-C. 50646 - The m...
• VologdaInterCity-D. 50605 - Behind...
• 50580 - Days passed
• 50623 - Rectangles
• 50645 - Line
• 50762 - Rare name

Feedback

If you notice incorrect translations in Contester, please let author know.

Time limit 2000/4000/4000/4000 ms. Memory limit 65000/65000/65000/65000 Kb. Difficulty Alpha

Most modern text editors are able to give some statistics about the text they are editing. One nice statistic is the average word length in the text. A word is a maximal continuous sequence of letters ('a'-'z', 'A'-'Z'). Words can be separated by spaces, digits, and punctuation marks. The average word length is the sum of all the words' lengths divided by the total number of words.

For example, in the text "This is div2 easy problem". There are 5 words: "This"is"div"easy" and "problem". The sum of the word lengths is 4+2+3+4+7 = 20, so the average word length is 20/5 = 4.
Given a text, return the average word length in it. If there are no words in the text, return 0.0.

Input
The first line will contain the text of length between 0 and 50 characters inclusive. Text will contain only letters ('a'-'z', 'A'-'Z'), digits ('0'-'9'), spaces, and the following punctuation marks: ',', '.', '?', '!', '-'. The end of text will be marked with symbol '#' (see examples for clarification).
Output
Output should contain one number - the average length. The returned value must be accurate to within a relative or absolute value of 10-9.

Input 1 Input 2 Input 3
This is div2 easy problem.#
a bc#
w84lFC1hD2ot2?43 Jnw67Kmt8KhOQn#
Output 1 Output 2 Output 3
4.0
1.5
2.714285714

Для отправки решений необходимо выполнить вход.

www.contester.ru