模板
#include<stdio.h>
#include<string.h>
#define max 1000005
int trie[max][26];
int time[max];
int cnt=0;
void insert(char *s){
int root=0;
int len=strlen(s);
for(int i=0;i<len;i++){
int id=s[i]-'a';
if(trie[root][id]==0){
// printf("in new\n");
trie[root][id]=cnt++;
}
root=trie[root][id];
time[root]++;
}
}
int search(char *s){
int root=0;
int len=strlen(s);
for(int i=0;i<len;i++){
int id=s[i]-'a';
if(trie[root][id]==0)
return false;
root=trie[root][id];
}//root 经过循环后变为s字符串的最后一个字符所在位置
return time[root];
}
int main(){
cnt=1;
memset(time,0,sizeof(time));
char s[15];
while(gets(s)&&s[0]!='\0') insert(s);
while(gets(s)) printf("%d\n",search(s));
return 0;
}