20130820 【南华大学 ACM】 个人选拔赛第二场 【A . BAKA】

来源:互联网 发布:vivo网络授权书怎么 编辑:程序博客网 时间:2024/05/01 10:23

Problem A: BAKA

Time Limit: 1 Sec  Memory Limit: 32 MB
[Submit][Status][Web Board]

Description

Mirko's grandma still uses an ancient pulse dial telephone with a rotary dial as shown in the following
picture:

For   each   digit   that  we  want   to   dial, we   need  to   turn   the   rotary   dial clockwise   until   the   chosen  digit
reaches the finger stop (metal fin). Then we let go of the dial and wait for it to return to its original
position   before   we   can   dial   another   digit.   In   our   modern,   instant   gratification   world,   the   dial   return
often   lasts   much   longer   than   our   patience.   More   precisely,   dialling   the   digit   1   takes   a  total   of   two
seconds,   while   dialling   any   larger   digit   takes   an   additional   second   for   each   additional   finger   circle
counting from 1 to the dialled digit (as shown in the picture).
Mirko's   grandma      remembers   phone   numbers   by        memorizing   a   corresponding   word   which,   when
dialled, results in the correct number being dialled. When dialling a word, for each letter, we dial the
digit which has that letter written next to it on the dial (for example, the digit  7 for the letter S). For
example, the word UNUCIC1  corresponds to the number 868242. Your task is determining, for a given

word, the total time required to dial that word.

Input

The   first   and   only   line   of   input   contains   a   single   word   consisting   of  between  2  and  15  (inclusive)
uppercase English letters.

Output


The first and only line of output must contain the required dialling time.

Sample Input

WAUNUCIC

Sample Output

1336

HINT

In test data worth at least 30% of total points, the input word will contain only vowels.


In test data worth an additional     30% of total points, the input word will contain only letters smaller than

P.

----------------------------------------------------------------------------------------------------------------------


来自地球的水题,没什么好说的。


----------------------------------------------------------------------------------------------------------------------

#include<stdio.h>#include<string.h>int main(){int num[30]={2,2,2,3,3,3,4,4,4,5,5,5,6,6,6,7,7,7,7,8,8,8,9,9,9,9};int i;char ch[20];int len,sum;while( EOF != scanf("%s",ch) ){len = strlen(ch);for(i=0,sum=0;i<len;i++){sum += num[ ch[i] - 'A' ] +1;}printf("%d\n",sum);}return 0;}


改—_—

#include <stdio.h>char num[27]="22233344455566677778889999", s[30];int main(){while( EOF != scanf("%s", s) ){int ans = 0;for(int i=0; s[i]; i++)ans += num[ s[i]-'A' ]-'0'+1;printf("%d\n", ans);}return 0;}


原创粉丝点击