https://www.luogu.com.cn/problem/P1765
#include <iostream>
#include <cstdio>
#include <cstring>
#include <sstream>
#include <algorithm>
using namespace std;
long long qmi(int m, int k)
{
int res = 1, t = m;
while (k)
{
if (k&1) res = res * t;
t = t * t;
k >>= 1;
}
return res;
}
int read(){
int x = 0,f = 1;
char c = getchar();
while (c<'0'||c>'9') {
if (c=='-') {
f = -1;
}
c = getchar();
}
while (c>='0'&&c<='9') {
x = x*10+c-'0';
c = getchar();
}
return x*f;
}
int key[30] = {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};
int main()
{
string str;
getline(cin, str);
int click = 0;
for (int i = 0; i<str.length(); i++) {
if(str[i] >= 'a' && str[i] <= 'z')
click += key[(str[i] - 'a')];
else if(str[i] == ' ')
click ++;
}
cout<<click;
return 0;
}
/*
i have a dream
============
23
*/
网友评论