#include<iostream>
#include<string>
#include<cstring>
#include<sstream>
#include<cctype>
#include<string.h>
#include<algorithm>
#include<cmath>
#include<stack>
#include<fstream>
#include<cstdlib>
#include<vector>
#include<map>
#include<utility>
#include<iomanip>
using namespace std;
int main()
{
long long n,i,k,x;
vector<long long>name;
map<long long, long long>occ;
map<long long, long long>b;
name.clear();
occ.clear();
b.clear();
while(cin>>x)
{
if(b[x]!=1){
b[x]=1;
name.push_back(x);
occ[x]++;
}
else occ[x]++;
}
k=name.size();
for(i=0;i<k;i++)
{
cout<<name[i]<<" "<<occ[name[i]]<<endl;
}
return 0;
}
may i know what's the b and occ for?
ReplyDeleteb to check whether the number is already taken or not, in other word, b is to check duplicate.
ReplyDeleteocc is to count how many times the number occurred.