/*实践再次说明ch=getchar()的速度非常慢*/
/*大水题,不解释*/
#include<stdio.h>
#include<string.h>
int main()
{
int i,j,n,count;
int a[];
char ch,s[];
j=;
for(i=; i<=; i++)
{
if(j>) j=;
a[i]=j;
j++;
}
a[]=;
a[]=;
a[]=;
a[]=;
a[]=;
a[]=;
a[]=;
a[]=;
a[]=;
scanf("%d",&n);
getchar();
for(i=; i<=n; i++)
{
count=;
gets(s);
for(j=;j<strlen(s);j++)
count+=a[s[j]];
printf("%d\n",count);
}
return ;
}

时间限制:500MS  内存限制:1000K 提交次数:95 通过次数:27

题型: 编程题   语言: C++;C

Description

Now almost every student has a mobile telephone. But do you have making attention to the keyboard of a mobile telephone? This is the keyboard of a normal mobile telephone:

It will show different letters if you press one key different times, for example you press the key “2” once it will show a letter ‘a’, twice show a ‘b’. And notice that press the key ‘0’ once will show a space. Now give you a sentence, which contains only lowercases and space, calculate how much times to press the keyboard at least to show the sentence.

输入格式

The first line contains an integer n, which means the number of cases. Per case consist of only one sentence, which contains only lowercases and spaces and its length less or equal 200.

输出格式

Per case output an integer, which is the least times to press the keyboard, in one line.

输入样例

1this problem is so easy

输出样例

53

Time:15ms

最新文章

  1. Spring浅探
  2. haproxy log config
  3. 10年程序员谈.Net程序员的职业规划(图/文) (转载)
  4. Struts标签&lt;s:iterator&gt;遍历访问复杂Map对象
  5. 如何用PowerPoint制作闪烁的星星
  6. .net技术深入
  7. Unity 游戏框架搭建 (二十) 更安全的对象池
  8. 详解卷积神经网络(CNN)在语音识别中的应用
  9. Python模块 - configparser
  10. 五子棋.html
  11. Node中包的加载机制
  12. java 将指定文件夹递归的进行zip打包压缩
  13. faster-rcnn 笔记
  14. Docker Swarm 创建服务
  15. Speeding Up The Traveling Salesman Using Dynamic Programming
  16. Windows平台下搭建自己的Git服务器
  17. Pairs Forming LCM (LCM+ 唯一分解定理)题解
  18. Custom Settings.in 配置信息收集
  19. Apache 调用不同的 PHP 版本
  20. Python Twisted系列教程8:使用Deferred的诗歌下载客户端

热门文章

  1. oracle一条sql语句统计充值表中今天,昨天,前天三天充值记录
  2. 关于Cookie和Session的优缺点
  3. DB2 create partitioned table
  4. js函数的几个特殊点
  5. js对象
  6. Hibernate中一对多和多对一关系
  7. ***PHP Notice: Undefined index: ..问题的解决方法
  8. iphone手机不同版本兼容、横竖屏
  9. TortoiseSVN常用操作说明
  10. PHP_Memcache函数详解