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;}
- 20130820 【南华大学 ACM】 个人选拔赛第二场 【A . BAKA】
- 20130820 【南华大学 ACM】 个人选拔赛第二场 【B . SUME】
- 20130820 【南华大学 ACM】 个人选拔赛第二场 【C . DOBRI】
- 南华大学ACM第一场个人联系赛 A Eming
- 南华大学ACM个人练习 第二场 D: The mell hall
- 20130709 【南华大学 ACM】 新生赛第二场 【F. Little Sheep and a paper】
- 南华大学ACM 个人练习第一场 B.Arithmetic Progression
- 南华大学ACM个人连续第一场 E.Function
- 20130709 【南华大学 ACM】 新生赛第二场 【G. Matrix】
- 20130707 【南华大学 ACM】 新生赛第一场 【A.Eming】
- 中南大学2016年校队选拔赛第二场Problem A
- 20130709 【南华大学 ACM】 新生赛第二场 【B. Dating With Girls】
- 20130709 【南华大学 ACM】 新生赛第二场 【D: The mell hall】
- 20130712 【南华大学 ACM】 新生赛第三场 【B. A simple problem】
- 南华大学暑假个人练习第三场 B. A simple problem
- 20130707 【南华大学 ACM】 新生赛第一场 【D.Brackets】
- 20130707 【南华大学 ACM】 新生赛第一场 【E.Function】
- 南华大学个人练习第三场F.Help Johnny
- 杭电多校联赛<9>
- 搜索引擎算法之初探——PageRank、DocRank
- 离开前请叫醒我
- Hibernate 反向工程生成的 DAO 文件 save 方法
- PHP面试题(一)
- 20130820 【南华大学 ACM】 个人选拔赛第二场 【A . BAKA】
- NFS服务器搭建
- 构建tftp服务器
- HDU_2035 人见人爱A^B
- C# 中的委托和事件
- 模块调试
- GDB和GDB Server交叉调试
- hdu 1059
- 存储过程基本介绍