http://acm.fjnu.edu.cn/show?problem_id=1769
打表,注意如果是其他字符,就不增加按键次数。
import java.util.*;
import java.io.*;


public class ACM_1769
{
public static void main(String rgs[]) throws Exception

{
BufferedReader stdin =
new BufferedReader(
new InputStreamReader(System.in));

int[] a=new int[]
{0,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};
String s =null;

while((s = stdin.readLine())!=null)
{
int count=0;

for(int i=0;i<s.length();i++)
{
char c=s.charAt(i);
if(c>='a' && c<='z')
count+=a[c-96];
else if(c==' ')
count++;
}
System.out.println(count);
}
}
}
posted on 2009-09-27 10:22
飞翔天使 阅读(204)
评论(0) 编辑 收藏 所属分类:
ACM