WritingWords
SRM 618 · 2013-12-22 · by ltaravilse
SRM 618 · 2013-12-22 · by ltaravilse · Brute Force, Simulation
Problem Statement
Problem Statement
Fox Ciel wants to type a word on her old cell phone. The cell phone has only one button. The letter A is typed by tapping the button once, B by tapping it twice in a row, and so on, in alphabetical order. Thus, the last letter Z is typed by tapping the button 26 times without a pause.
You are given aString word. Compute and return the answer to the following question: How many times will Ciel tap the button while typing this word?
You are given a
Notes
- While typing a word, Ciel has to make a short pause after typing each letter, so that the phone can tell when one letter ends and another letter begins. These pauses do not matter in this problem.
Constraints
- word will contain between 1 and 50 characters, inclusive.
- Each character in word will be an uppercase English letter ('A'-'Z').
Examples
0)
"A" Returns: 1
One tap types the letter A.
1)
"ABC" Returns: 6
To type ABC, Ciel will do the following: Tap the button once to type A. Tap the button twice to type B. Tap the button three times to type C. The total number of taps is 1+2+3 = 6.
2)
"VAMOSGIMNASIA" Returns: 143
3)
"TOPCODER" Returns: 96
4)
"SINGLEROUNDMATCH" Returns: 183
Submissions are judged against all 39 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Coding Area
Language: C++17 · define a public class WritingWords with a public method int write(string word) · 39 test cases · 2 s / 256 MB per case