Https://www.luogu.org/problem/show?pid=1765#sub Topic Description
The general phone's keyboard is like this:
1 2 ABC 3 def
4 Ghi 5 JKL 6 MnO
7 PQRS 8 TUV 9 WXYZ
* 0 #
To press the English letter, you have to press the number key more. For example, to press the X to press 92, the first will be a W, and the second will turn W into X. 0 Click to make a space.
Your task is to read a few sentences that contain only English lowercase letters and spaces, and find out how much you need to press the keyboard at least to hit the sentence on your phone.
Input/output format
Input format:
A single sentence, containing only English lowercase letters and spaces, and no more than 200 characters.
Output format:
An integer line that represents the total number of times that the keyboard was pressed.
Input and Output Sample input example # #:
I have a dream
Sample # # of output:
23
Description
_noi Guide Issue 2010 popularity (10)
1#include <algorithm>2#include <cstring>3#include <cstdio>4 5 using namespacestd;6 7 intans,cnt[ -]={1,2,3,1,2,3,1,2,3,1,2,3,1,2,3,1,2,3,4,1,2,3,1,2,3,4,1};8 Chars[ $];9 Ten intMain () One { A gets (s); - for(intI=0; I<strlen (s); i++) - { the if(s[i]==' ') ans++; - Else if(s[i]>='a'&&s[i]<='Z') ans+=cnt[s[i]-'a']; - } -printf"%d", ans); + return 0; -}
Rokua--p1765 Mobile Phone _noi Guide Issue 2010 popularization (10)