#include<stdio.h>
int a[30], k1, k2, ans;
char c;
int main()
{
a[1] = 11, a[2] = 12, a[3] = 13;
a[4] = 21, a[5] = 22, a[6] = 23;
a[7] = 31, a[8] = 32, a[9] = 33;
a[10] = 41, a[11] = 42, a[12] = 43;
a[13] = 51, a[14] = 52, a[15] = 53;
a[16] = 61, a[17] = 62, a[18] = 63, a[19] = 64;
a[20] = 71, a[21] = 72, a[22] = 73;
a[23] = 81, a[24] = 82, a[25] = 83, a[26] = 84;
while (scanf("%c", &c) == 1)
{
if (c == '\n')
{
printf("%d\n", ans);
k2 = 0, ans = 0;
continue;
}
k1 = c - 'a' + 1;
if ((a[k1] / 10) == (a[k2] / 10))
ans += 2;
ans += a[k1] % 10;
k2 = k1;
}
printf("%d\n", ans);
return 0;
}
acwing 3381.手机键盘
最新推荐文章于 2024-09-09 23:37:48 发布