#include <stdio.h>
int main()
{
freopen("input.txt", "r", stdin);
int test_case, T;
int ctoi[26] = { 2,2,2,3,3,3,4,4,4,5,5,5,6,6,6,7,7,7,7,8,8,8,9,9,9,9 };
char S[5];
int N;
char str[10];
int count;
int i, j;
scanf("%d", &test_case);
for (T = 0; T < test_case; ++T)
{
count = 0;
scanf("%s %d", S, &N);
for (i = 0; i < N; ++i)
{
scanf("%s", str); // 단어하나씩 확인함
j = 0;
while ((S[j] != '\0') && (str[j] != '\0')) // 순서대로 들어오므로,
{
if ((S[j] - '0' != ctoi[str[j] - 'a'])) // 이 단어가 이 키패드에 해당하는지 확인
break;
++j; // 오케이면 오케이
}
if (S[j] == '\0')
++count; // 마지막 숫자에 다다르면, count++
}
printf("%d\n", count);
}
return 0;
}
댓글