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
6754 Keyboard of a Mobile Telephone的更多相关文章
- Mobile Push Notification
In one embodiment, a method includes sending to a mobile client computing device a first notificatio ...
- [React Native] Prevent the On-screen Keyboard from Covering up Text Inputs
When you bring up the on screen keyboard in a mobile app, it will cover any text input or buttons on ...
- Operating system management of address-translation-related data structures and hardware lookasides
An approach is provided in a hypervised computer system where a page table request is at an operatin ...
- Indexing Sensor Data
In particular embodiments, a method includes, from an indexer in a sensor network, accessing a set o ...
- Tagging Physical Resources in a Cloud Computing Environment
A cloud system may create physical resource tags to store relationships between cloud computing offe ...
- jqgrid(转载)
一.主要API接口getGridParam.setGridParam: getGridParam方法: getGridParam("url"): 获取当前的AJAX的URL get ...
- WAP网页输入框的默认键盘类型控制
最近有用户反映手机网的输入框不够人性化,比如手机号.卡号输入框应该默认显示数字键盘,邮箱输入框应该默认显示邮箱键盘. 百度上对这样的资料介绍很多,基本上都和这个页面是一个意思 http://www.w ...
- JavaScript验证
<script type="text/javascript"> /*密码*/ function password() { var pas ...
- MYSQL系列1_MySQL的安装,可视化工具的使用,以及建库建表等
大家都知道MYSQL是开源的数据库,现在MYSQL在企业中的使用也越来越多,本人之前用过SQL SERVER数据库,因业务需要和自己的兴趣想要学习MYSQL,对于MYSQL,本人还是新手,请大家多多指 ...
随机推荐
- LeetCode 231 Power of Two
Problem: Given an integer, write a function to determine if it is a power of two. Summary: 判断一个数n是不是 ...
- IOS - SDWebImage 非ARC 问题
非arc项目中使用SDWebImage类库 1.添加类库引用 (1)ImageIO.framework (2)MapKit.framework 2.在targets->build P ...
- osg设置相机参数,包括初始位置
严重注意!!!以下设置必须在viewer.realize();之后,否则不起作用!!!! 设置相机的位置,可以通过CameraManipulator(一般是osgGA::TrackballManipu ...
- Android之WebView学习
WebView常用方法 WebSettings 在使用WebView前我们都要进行相关的配置,常见的操作如下: WebSettings settings = mWebView.getSettings( ...
- DNS原理
DNS 是互联网核心协议之一.不管是上网浏览,还是编程开发,都需要了解一点它的知识. 本文详细介绍DNS的原理,以及如何运用工具软件观察它的运作.我的目标是,读完此文后,你就能完全理解DNS. 一.D ...
- sqlserver执行sql文件命令(sqlcmd)
个人自用sqlcmd命令: sqlcmd -E -i test.sql -d databasename -s 127.0.0.1 sqlcmd命令解释: 用法: Sqlcmd [ ...
- Java -- 子类使用super调用父类的方法A,A 调用了方法B,子类也override方法B,那么super.A()最终调用到了子类的B方法
public class SuperClass{ public void printA(){ System.out.print("SuperClass-printA"); prin ...
- 19.状态者模式(State Pattern)
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...
- Oracle数据库锁表及解锁进程
下午代码迁移,更新数据库记录时for update语句无法执行,数据库被锁,KILL掉几个进程搞定. Oracle数据库操作中,我们有时会用到锁表查询以及解锁和kill进程等操作,那么这些操作是怎么实 ...
- Android init.rc执行顺序
转自:http://blog.csdn.net/kickxxx/article/details/7590665 1. 所有的action运行于service之前 2. 下面为各个section的执行 ...