https://www.swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AWLL7kaaAPsDFAUW&categoryId=AWLL7kaaAPsDFAUW&categoryType=CODE
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.StringReader;
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;
public class Solution {
static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
static StringBuilder sb;
static StringTokenizer tokens;
static int T;
static int[][] map;
static Map<Character, Integer> keymap = new HashMap<>();
// 키의 매핑은 모든 상황에서 동일하게 지정됨
private static void init() {
for(char c='a'; c<='z'; c++) {
if(c<='c') {
keymap.put(c, 2);
}else if(c<='f') {
keymap.put(c, 3);
}else if(c <='i') {
keymap.put(c, 4);
}else if(c<='l') {
keymap.put(c, 5);
}else if(c<='o') {
keymap.put(c, 6);
}else if(c<='s') {
keymap.put(c, 7);
}else if(c<='v') {
keymap.put(c, 8);
}else if(c<='z') {
keymap.put(c, 9);
}
}
}
public static void main(String[] args) throws NumberFormatException, IOException {
init();
sb = new StringBuilder();
br = new BufferedReader(new StringReader(src));
T = Integer.parseInt(br.readLine());
StringBuilder inputToNum = null;
for (int t = 1; t <= T; t++) {
int answer = 0;
tokens = new StringTokenizer(br.readLine());
String input = tokens.nextToken();
tokens.nextToken();// 버림
tokens = new StringTokenizer(br.readLine());
String word = null;
while(tokens.hasMoreTokens()) {
word = tokens.nextToken();
inputToNum = new StringBuilder();
for(int i=0; i<word.length(); i++) {
Character c = word.charAt(i);
inputToNum.append(keymap.get(c));
}
if(input.equals(inputToNum.toString())) {
answer++;
}
}
sb.append(String.format("#%d %d\n", t, answer));
}
System.out.println(sb);
}
static String src = "3\r\n" +
"6666 3\r\n" +
"tomo mono dak\r\n" +
"52 2\r\n" +
"ja la\r\n" +
"366 3\r\n" +
"dom fon tom";
}