P1097 [NOIP2007 提高组] 统计数字
#include<cstdio> #include<cstring> #include<iostream> #include<algorithm> #include<bits/stdc++.h> #define ll long long #define ddd printf("-----------------debug\n"); using namespace std; map<int,int> a; set<int> b; int n; int main() { ios::sync_with_stdio(false); cin>>n; for(int i=1;i<=n;i++) { int x; cin>>x; a[x]++;//map key k-- b.insert(x); } for(set<int>::iterator it=b.begin();it!=b.end();it++) { cout<<*it<<" "<<a[*it]<<endl; } return 0; }

浙公网安备 33010602011771号