hdu 4287
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4287
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
#include<cstdio> #include<cstring> #include<iostream> #include<algorithm> using namespace std; const int maxn = 5500; const int maxm = 1e6; int num[maxm]; int map[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 }; int a[7] = {1,10,100,1000,10000,100000}; int main() { //freopen("E:\\acm\\input.txt","r",stdin); int T; cin>>T; while(T--){ int N,M; scanf("%d %d",&N,&M); int Q[maxn]; for(int i=1;i<=N;i++) scanf("%d",&Q[i]); memset(num,0,sizeof(num)); for(int i=1;i<=M;i++){ char s[10]; scanf("%s",s); int len = strlen(s); int sum = 0,cnt =0; for(int i=len-1;i>=0;i--){ int temp = map[s[i]-'a']; sum += temp * a[cnt++]; } num[sum]++; } for(int i=1;i<=N;i++) printf("%d\n",num[Q[i]]); } return 0; }