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