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

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

WA
UNUCIC

Sample Output

13
36

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;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值