Rokua--p1765 Mobile Phone _noi Guide Issue 2010 popularization (10)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.