水题 ZOJ 3869 Ace of Aces
2015-04-26 13:37
176 查看
题目传送门
水题,找出出现次数最多的数字,若多个输出Nobody
水题,找出出现次数最多的数字,若多个输出Nobody
//#include <bits/stdc++.h> //using namespace std; #include <cstdio> //stdio.h #include <cstring> //string.h #include <algorithm> const int N = 1e3 + 5; struct Hash { int num, cnt; bool operator < (const Hash &r) const { return cnt < r.cnt; } }h ; //bool cmp(const Hash &a, const Hash &b) { //更规范的写法 bool cmp(Hash a, Hash b) { return a.cnt < b.cnt; //按照计数cnt从小到大排 } int main(void) { int T; scanf ("%d", &T); while (T--) { int n; scanf ("%d", &n); memset (h+1, 0, sizeof (h)); for (int x, i=1; i<=n; ++i) { scanf ("%d", &x); h[x].num = x; h[x].cnt++; } //std::sort (h+1, h+1+1000, cmp); //cmp比较函数写在结构体外面 std::sort (h+1, h+1+1000); //结构体重载运算符 '<' if (h[1000].cnt == h[999].cnt) puts ("Nobody"); else printf ("%d\n", h[1000].num); } return 0; }
相关文章推荐
- ZOJ3869 Ace of Aces
- ZOJ 3869:Ace of Aces【水】
- ZOJ Problem Set - 3869||Ace of Aces
- Ace of Aces ZOJ - 3869
- zoj 3869 Ace of Aces (水题)
- ZOJ-3869 Ace of Aces
- zoj-3869-Ace of Aces
- ZOJ 3869 Ace of Aces
- ZOJ 3869 Ace of Aces
- ZOJ 3869 Ace of Aces
- ZOJ 3869 Ace of Aces (The 12th Zhejiang Provincial Collegiate Programming Contest)
- ZOJ 3869 -- Ace of Aces
- ZOJ - 3869 Ace of Aces (水)
- A - Ace of Aces ZOJ - 3869 -mystical_curve
- zoj 3869 Ace of Aces
- ZOJ 3869-Ace of Aces【模拟众数】
- ACM刷题之ZOJ————Ace of Aces
- A - Ace of Aces——ZOJ
- 12th.浙江省省赛A题 Ace of Aces
- Ace of Aces