Keyboard of a Mobile Telephone 时间限制:500MS 内存限制:1000K
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.
输入样例
1
this problem is so easy
输出样例
53
来源
By Hanqiu
恰好学了一种叫map(映射)的东西。于是乎暴力之。
#include <cstdio>
#include <cstring>
#include <cmath>
#include <queue>
#include <vector>
#include <string>
#include <stack>
#include <set>
#include <map>
#include <iostream>
#include <bitset>
#include <algorithm>
using namespace std;
int main() {
map<char,int> Iphone;
Iphone['a']=Iphone['d']=Iphone['g']=Iphone['j']=Iphone['m']=Iphone['p']=Iphone['t']=Iphone['w']=Iphone[' ']=1;
Iphone['b']=Iphone['e']=Iphone['h']=Iphone['k']=Iphone['n']=Iphone['q']=Iphone['u']=Iphone['x']=2;
Iphone['c']=Iphone['f']=Iphone['i']=Iphone['l']=Iphone['o']=Iphone['r']=Iphone['v']=Iphone['y']=3;
Iphone['s']=Iphone['z']=4;
int T;
char s[205];
scanf("%d",&T);
getchar();
while(T--){
gets(s);
int l=strlen(s),c=0;
for(int i=0;i<l;++i)
c+=Iphone[s[i]];
printf("%d\n",c);
}
return 0;
}
就是手打的有点累- -
CTRL+C