当前位置:网站首页>Mobile keyboard (simulation question)
Mobile keyboard (simulation question)
2022-07-19 10:45:00 【Like a few dollars】
Please calculate according to the mobile phone keyboard (99 Key input method ) How to enter letters , Type the given string ( Consisting of lowercase letters ) The time it takes .
The specific typing rules and time spent are described below :
For characters on the same key , for example a,b,ca,b,c All in “1” On key , Input aa Just press once , Input cc You need to press it three times in a row .
If two consecutive characters are not on the same key , You can press , Such as :adad Need to press twice ,kzkz Need to press 66 Next .
If two consecutive characters are on the same key , You need to wait a while between the two buttons , Such as acac, I pressed aa after , It will take a while to press cc.
Now suppose it takes a period of time to press each time , The waiting time takes two time periods .
Input format
Input contains multiple sets of test data .
Each group of data occupies one row , Contains a string of lowercase letters .
Output format
For each group of input , One line of output indicates the time it takes to type a given string .
Data range
Each input contains at most 100100 Group test data .
All strings are no longer than 100100.sample input :
bob wwwsample output :
7 7
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
int number[]={
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 main()
{
string str;
while(cin>>str)
{
int res=0;
int last=-1;
for( auto c:str)
{
int t=c-'a';
for(int i=t;i>=0;i--)
{
if(number[i]==number[t]) res++;
else break;
}
if(number[last]==number[t]) res+=2;
last=t;
}
cout<<res<<endl;
}
return 0;
}2022/7/12
边栏推荐
猜你喜欢
随机推荐
Avi 部署使用指南(2):Avi 架构概述
Pytorch框架 学习记录1 CIFAR-10分类
看一看这丑恶嘴脸 | MathWorks Account Unavailable - Technical Issue
unity3d中的旋转
空天地海一体化网络体系架构与网络切片技术
SAP AppGyver 简介
各厂商的数据湖解决方案
从“被动”到“主动”,ZETA技术助力“RFID2.0”升级该如何实现?
创建虚拟机第一章(vmvare虚拟机)
win10开始键点击无响应
Data Lake solutions of various manufacturers
Pytorch.nn实现多层感知机
如何使用SVG制作沿任意路径排布的文字效果
[Acwing] 第 60 场周赛 C-AcWing 4496. 吃水果
华为防火墙(NGFW)的双机热备
追根问底:Objective-C关联属性原理分析
unity3d如何利用asset store下载一些有用的资源包
高数__方程与函数的关系
R language ggplot2 visualization: use the ggstripchart function of ggpubr package to visualize dot strip plot, and set the add parameter to mean_ SD add the mean standard deviation vertical line and s
从预测到决策,九章云极DataCanvas推出YLearn因果学习开源项目










