题目1079:手机键盘
2017-04-15 15:21
302 查看
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <cstring>
#include <stack>
#include <string>
#include <string.h>
#include <stdio.h>
#include <cmath>
#include <map>
#include <functional>
#include <set>
#include <limits.h>
#include <math.h>
#include <ctype.h>
using namespace std;
//1079
int a[]={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 b[]={1,2,3,1,2,3,1,2,3,1,2,3,1,2,3,1,2,3,4,1,2,3,1,2,3,4};
char ch[101];
int ans;
bool isOne(char c1,char c2)
{
return (a[c1-'a']==a[c2-'a'])?true:false;
}
int main()
{
while(scanf("%s",ch)!=EOF)
{
ans=b[ch[0]-'a'];
for(int i=1;i<strlen(ch);i++)
{
if(isOne(ch[i-1],ch[i])==false)
ans+=b[ch[i]-'a'];
else
ans+=b[ch[i]-'a']+2;
}
printf("%d\n",ans);
}
return 0;
}
/**************************************************************
Problem: 1079
User: cust123
Language: C++
Result: Accepted
Time:10 ms
Memory:1520 kb
****************************************************************/
相关文章推荐
- 题目1079:手机键盘
- 题目1079:手机键盘答案
- 九度OJ 题目1079:手机键盘
- 题目1079:手机键盘(对应关系)
- 题目1079:手机键盘
- 模拟_题目1079:手机键盘
- 题目1079:手机键盘
- 九度OJ 题目1079:手机键盘
- 题目1079:手机键盘
- 九度oj-1079-手机键盘
- 九度OJ 1079 手机键盘
- 九度OJ 1079 手机键盘 (模拟)
- 九度OJ 1079 手机键盘
- 清华大学2008年机试-手机键盘-1079
- 九度OJ 1079:手机键盘 (翻译)
- 九度OJ 1079:手机键盘 (翻译)
- 九度OJ 1079 手机键盘
- 九度OJ 1079: 手机键盘
- LightOJ 题目1079 Just another Robbery(01背包)
- Elecom公司推出首款NFC手机键盘