Acjoy群赛D-Grade题解
来源:互联网 发布:手机淘宝首页怎么装修 编辑:程序博客网 时间:2024/05/29 14:37
#include <stdio.h>#include <string.h>#include<stdlib.h>#include<algorithm>using namespace std;const int N = 10005;int vis[N], n;struct Num { int value; int cnt;}num[N];bool cmp(Num a, Num b) {//结构体排序 if (a.cnt != b.cnt) return a.cnt > b.cnt; return a.value < b.value;}int main() { int t, cas = 1; scanf("%d", &t); while (t--) { memset(vis, 0, sizeof(vis)); scanf("%d", &n); int a, k = 0; for (int i = 0; i < n; i++) { scanf("%d", &a); int temp = 10000 - (100 - a) * (100 - a); if (!vis[temp]) { vis[temp]++; num[k].cnt = 0; num[k++].value = temp; } else vis[temp]++; } for (int i = 0; i < k; i++) num[i].cnt = vis[num[i].value];//这样可以避免再次从头到尾的查找 sort(num, num + k, cmp); int m = 1; for (int i = 0; i < k - 1; i++) { if (num[i].cnt == num[i + 1].cnt) m++; else break; } if (m == k && k != 1) { printf("Case #%d:\nBad Mushroom\n", cas++); continue; } printf("Case #%d:\n", cas++); printf("%d", num[0].value); for (int i = 1; i < m; i++) printf(" %d", num[i].value); printf("\n"); } return 0;}
1 0
- Acjoy群赛D-Grade题解
- 【AcJoy群赛题解】 群赛01
- 【AcJoy群赛题解】 群赛02
- Acjoy群赛02-C - HopscotcH
- POJ3666Making the Grade题解动态规划DP
- grade
- BUPT Summer Training #7 for Grade 14 题解
- POJ3666 Making the Grade题解-动态规划dp
- ACJoy A Presents
- ACJoy C Beautiful Year
- CF 89D 题解
- codeforces 594D题解
- codeforces D. Ice Sculptures 题解
- Google APAC Round D题解
- Codeforces 325D Reclamation 题解
- Codeforces 475D CGCDSSQ 题解
- Codeforces-417D总结&题解
- [题解]codeforces413e Maze 2D
- getHibernateTemplate()和getSession()区别(转)
- lambda环境搭建
- find_in_set
- 蓝桥杯校赛题目以及解析
- 【杭电】[2003]求绝对值
- Acjoy群赛D-Grade题解
- Oracle 定义类型
- 值得你关注的Android6.0上的重要变化(二)
- 关于java的字符串操作
- C语言 二分查找
- debugfs使用软件查看gpio状态
- Android 单个App显示多个任务列表预览视图
- spring中@ResponseBody ajax返回处理信息给前台 中文乱码问题
- OAuth 2.0