思路:这种串数字统计每个数字出现次数的题型都可以用map做,简单,CCF有好几道类似的题目,可以把它当做一个模板使用。
#include <iostream>
#include <map>
using namespace std;
int main(){
int n,v;
cin>>n;
map<int,int> m;
for(int i = 0; i < n; i++){
cin>>v;
m[v]++;
cout<<m[v]<<' ';
}
return 0;
}