Description
Input
注意:本题只有一组测试数据,处理到文件结束.
Output
Sample Input
Sample Output
map可能比较耗时,但是这题能过
#include <cstdio>
#include <iostream>
#include <map>
#include <cstring>
#include <string>
using namespace std;
int main()
{
char str[17];
map<string, int> m;
while(gets(str))
{
int len = strlen(str);
if (!len)
{
break;
}
for(int i = len; i > 0; i--)
{
str[i] = '\0';
m[str]++;
}
}
while(gets(str))
{
cout<<m[str]<<endl;
}
return 0;
}