2009年6月11日 星期四

ACM Q11530



import java.util.Scanner;
public class Main {
public static void main(String args[]) {
Scanner cin = new Scanner(System.in);
int T = cin.nextInt();
cin.nextLine();
for(int i=0; i< T; i++){
int count =0;
String line = cin.nextLine();
char[] lineAry = line.toCharArray();
for(int j=0; j<lineAry.length; j++){
int tmp = lineAry[j];
if(tmp<112&& tmp>= 97){
count += ((int)lineAry[j]-1)%3+1;
}else if(lineAry[j]=='p'||lineAry[j]=='t'||lineAry[j]=='w'||lineAry[j]==' '){
count +=1;
}else if (lineAry[j]=='q'||lineAry[j]=='u'||lineAry[j]=='x'){
count +=2;
}else if (lineAry[j]=='r'||lineAry[j]=='v'||lineAry[j]=='y'){
count +=3;
}else if (lineAry[j]=='s'||lineAry[j]=='z'){
count +=4;
}
}
System.out.println("Case #"+(i+1)+": "+count);
}
}
}

沒有留言:

張貼留言