Description
给你一个序列,有N个整数(int以内),判断一个数在这个序列中出现几次。
Input
多组输入,输入到文件结尾
首先输入一个n,然后输入n个整数。
在输入一个m,代表查询的个数 ,然后输入m个数(int以内)。
n,m <= 100000;
Output
对应每一次查询,输出这个数在序列中出现几次。
Sample
Input
5
1 2 2 3 5
3
2 4 5
Output
2
0
1
#include <bits/stdc++.h>
using namespace std;
int a[100010];
int main()
{
int n,m,x;
while(~scanf("%d",&n))
{
for(int i=0; i<n; i++)
{
scanf("%d",&a[i]);
}
map<int,int>ma;
for(int i=0; i<n; i++)
{
ma[a[i]]++;
}
scanf("%d",&m);
while(m--)
{
scanf("%d",&x);
cout<<ma[x]<<endl;
}
}
return 0;
}