当前位置:网站首页>3381. Mobile keyboard (Tsinghua University postgraduate entrance examination machine test question)
3381. Mobile keyboard (Tsinghua University postgraduate entrance examination machine test question)
2022-07-27 04:05:00 【Ray.C.L】

Ideas : simulation
Code :
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
int numbers[] = {
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 s;
while(cin >> s){
int last = -1, res = 0;
for(auto c : s){
int t = c - 'a';
for(int i = t; i >= 0; i --)
if(numbers[t] == numbers[i])
res ++;
else
break;
if(numbers[t] == numbers[last]) res +=2;
last = t;
}
printf("%d\n", res);
}
return 0;
}
边栏推荐
- C#怎么实现给Word每一页设置不同文字水印
- Restful Fast Request 2022.2.2发布,支持批量导出文档
- On the first day of Shenzhen furniture exhibition, the three highlights of Jin Ke'er booth were unlocked!
- VR全景现在是不是刚需?看完你就明白了
- First pass of routing strategy
- NFT数字藏品系统开发:小蚁数智帮助品牌一键上链发行NFT
- Briefly sort out the dualpivotquicksort
- [Android synopsis] kotlin multithreaded programming (I)
- 【无标题】
- 回归测试:意义、挑战、最佳实践和工具
猜你喜欢
随机推荐
Realization of regular hexagon map with two-dimensional array of unity
A. Parkway Walk
基于风能转换系统的非线性优化跟踪控制(Matlab代码实现)
Kettle reads file split by line
A. YES or YES?
Cocos game practice-04-collision detection and NPC rendering
NFT数字藏品系统开发:小蚁数智帮助品牌一键上链发行NFT
【OBS】circlebuf
VR全景人淘金“小心机”(上)
暑假加餐|有钱人和你想的不一样(第5天)+电力系统潮流仿真(文档和Matlab代码)
Director of meta quest content ecology talks about the original intention of APP lab design
C language force deduction question 43 string multiplication. Optimized vertical
飞腾腾锐 D2000 荣获数字中国“十大硬核科技”奖
VR全景制作在家装行业是谈单利器?这是为什么呢?
flink cdc 到MySQL8没问题,到MySQL5读有问题,怎么办?
B. ICPC Balloons
在Golang结构体中使用tag标签
【安卓小叙】Kotlin多线程编程(一)
Regression testing: meaning, challenges, best practices and tools
LeetCode 第二十八天








